diff --git a/src/dom/serialize-doctype.ts b/src/dom/serialize-doctype.ts deleted file mode 100644 index 4b142d1..0000000 --- a/src/dom/serialize-doctype.ts +++ /dev/null @@ -1,54 +0,0 @@ -/// - -const htmlEscape = (str: string | null): string => { - if (!str) - return ''; - - let escaped: string = ''; - str.split('').forEach(char => { - if (char == '&') { - char = '&'; - } else if (char == '\'') { - char = '''; - } else if (char == '"') { - char = '"'; - } else if (char == '<') { - char = '<'; - } else if (char == '>') { - char = '>'; - } - escaped += char; - }); - - return escaped; -} - -const createDocType = (doctype?: DocumentType | null): string => { - if (!doctype) - return ''; - - const name = htmlEscape(doctype.name); - const internalSubset = htmlEscape(doctype.internalSubset); - const publicId = doctype.publicId ? `"${htmlEscape(doctype.publicId)}"` : ''; - const systemId = doctype.systemId ? `"${htmlEscape(doctype.systemId)}"` : ''; - - return ``; -} - -let doctypePolicy: TrustedTypePolicy; -if ((window as any).trustedTypes) { - doctypePolicy = (window as any).trustedTypes.createPolicy('html2canvas', { - // @ts-ignore - createHTML: (ignored: string, doctype?: DocumentType | null): string => { - return createDocType(doctype); - } - }); -} - -export const serializeDoctype = (doctype?: DocumentType | null): string | TrustedHTML => { - if (doctypePolicy !== undefined) { - return doctypePolicy.createHTML('', doctype); - } else { - return createDocType(doctype); - } -}