| 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, |