diff --git a/src/clone-node.ts b/src/clone-node.ts index 860f8cd..489d616 100644 --- a/src/clone-node.ts +++ b/src/clone-node.ts @@ -41,7 +41,7 @@ async function appendChildNode( const childCloned = await cloneNode(child, context) - if (context.restoreScrollPosition) { + if (context.isEnable('restoreScrollPosition')) { restoreScrollPosition(node, childCloned) } diff --git a/src/create-context.ts b/src/create-context.ts index 1a379f7..9970795 100644 --- a/src/create-context.ts +++ b/src/create-context.ts @@ -59,7 +59,6 @@ export async function createContext(node: T, options?: Options & onCreateForeignObjectSvg: null, includeStyleProperties: null, autoDestruct: false, - restoreScrollPosition: false, ...options, // InternalContext @@ -114,6 +113,9 @@ export async function createContext(node: T, options?: Options & features, isEnable: (key: string): boolean => { + if (key === 'restoreScrollPosition') { + return typeof features === 'boolean' ? false : (features as any)[key] ?? false + } if (typeof features === 'boolean') { return features } diff --git a/src/options.ts b/src/options.ts index 36cadd4..3ed06f0 100644 --- a/src/options.ts +++ b/src/options.ts @@ -166,6 +166,13 @@ export interface Options { * default: true */ fixSvgXmlDecode?: boolean + + /** + * Render scrolled children with scrolled content + * + * default: false + */ + restoreScrollPosition?: boolean } /** @@ -208,11 +215,4 @@ export interface Options { * This can be useful for performance-critical scenarios. */ includeStyleProperties?: string[] | null - - /** - * Render scrolled children with scrolled content - * - * default: false - */ - restoreScrollPosition?: boolean }