Skip to content

Commit

Permalink
feat: hooks are supported to return promises
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed Nov 6, 2024
1 parent 0e095dd commit 67d75b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/converts/dom-to-foreign-object-svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ export async function domToForeignObjectSvg(node: any, options?: any): Promise<S
await Promise.all([...Array.from({ length: 4 })].map(runTask))
log.timeEnd('embed node')

onEmbedNode?.(clone)
await onEmbedNode?.(clone)

const svg = createForeignObjectSvg(clone, context)
svgDefsElement && svg.insertBefore(svgDefsElement, svg.children[0])
svgStyleElement && svg.insertBefore(svgStyleElement, svg.children[0])

autoDestruct && destroyContext(context)

onCreateForeignObjectSvg?.(svg)
await onCreateForeignObjectSvg?.(svg)

return svg
}
Expand Down
6 changes: 3 additions & 3 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,17 @@ export interface Options {
/**
* Triggered after a node is cloned
*/
onCloneNode?: ((cloned: Node) => void) | null
onCloneNode?: ((cloned: Node) => void | Promise<void>) | null

/**
* Triggered after a node is embed
*/
onEmbedNode?: ((cloned: Node) => void) | null
onEmbedNode?: ((cloned: Node) => void | Promise<void>) | null

/**
* Triggered after a ForeignObjectSvg is created
*/
onCreateForeignObjectSvg?: ((svg: SVGSVGElement) => void) | null
onCreateForeignObjectSvg?: ((svg: SVGSVGElement) => void | Promise<void>) | null

/**
* An array of style property names.
Expand Down

0 comments on commit 67d75b2

Please sign in to comment.