MCPcopy Index your code
hub / github.com/027xiguapi/code-box / handleStyles

Method handleStyles

utils/print.ts:58–78  ·  view source on GitHub ↗
(clone: HTMLElement, options: PrintOptions)

Source from the content-addressed store, hash-verified

56 }
57
58 private static handleStyles(clone: HTMLElement, options: PrintOptions): void {
59 if (options.globalStyles) {
60 const styles = document.querySelectorAll("style, link, meta, base, title")
61 styles.forEach((style) => clone.appendChild(style.cloneNode(true)))
62 } else if (options.mediaPrint) {
63 const printStyles = document.querySelectorAll("link[media=print]")
64 printStyles.forEach((style) => clone.appendChild(style.cloneNode(true)))
65 }
66
67 if (options.stylesheet) {
68 const stylesheets = Array.isArray(options.stylesheet)
69 ? options.stylesheet
70 : [options.stylesheet]
71 stylesheets.forEach((sheet) => {
72 const link = document.createElement("link")
73 link.rel = "stylesheet"
74 link.href = sheet
75 clone.appendChild(link)
76 })
77 }
78 }
79
80 private static removeUnwantedElements(
81 clone: HTMLElement,

Callers 1

getContentToPrintMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected