Skip to content

Commit

Permalink
~
Browse files Browse the repository at this point in the history
  • Loading branch information
yhdgms1 committed Jun 15, 2022
1 parent 6ac2574 commit 7a7ca6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ export const buildSvgDataURI: BuildSvgDataURI = async (node, options) => {
let { width, height } = options

for (const styleSheet of document.styleSheets) {
if (
!styleSheet.href ||
styleSheet.href.startsWith(window.location.origin)
) {
for (const { cssText } of styleSheet.cssRules) {
if (!styleSheet.href || styleSheet.href.startsWith(location.origin)) {
for (let { cssText } of styleSheet.cssRules) {
css += cssText
}
}
Expand Down Expand Up @@ -114,7 +111,7 @@ export const renderToBase64Png = (dataURI: string): Promise<string> => {
img.src = dataURI

img.onload = controller
img.onerror = controller
img.onerror = () => resolve('')
})
}

Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type Thenable<T> = Promise<T> | T
export type Hook = (value: string) => Thenable<string | void>
export type BuildSvgDataURI = (
html: HTMLElement,
options: Options
Expand All @@ -7,7 +8,7 @@ export type BuildSvgDataURI = (
export interface Options {
filterer?: (value: string, index?: number, array?: string[]) => boolean
fetcher?: (url: string) => Promise<string>
css?: (value: string) => Thenable<string | void>
css?: Hook
width: number
height: number
}

0 comments on commit 7a7ca6a

Please sign in to comment.