Commit bd570b9
fix: scope pdf_viewer.css to .rodaPdfViewer to prevent global CSS leakage
pdf_viewer.css sets :root CSS custom properties (including dark-mode
media queries like --csstools-color-scheme--light) that leaked into the
host application and affected unrelated components.
Instead of loading the file via a global <link>, we now fetch the CSS
text, replace every ':root' selector with '.rodaPdfViewer', and inject
the result as a <style> element. Since all PDF.js DOM elements are
descendants of .rodaPdfViewer, custom properties defined there are still
inherited by .pdfViewer, .page, .textLayer, and .highlight — but they
no longer pollute the rest of the page.
Falls back to a global <link> if fetch fails (e.g. strict CSP).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent df7d25c commit bd570b9
1 file changed
Lines changed: 41 additions & 7 deletions
Lines changed: 41 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
25 | 63 | | |
26 | 64 | | |
27 | 65 | | |
28 | 66 | | |
29 | 67 | | |
30 | 68 | | |
31 | 69 | | |
32 | | - | |
| 70 | + | |
33 | 71 | | |
34 | 72 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 73 | + | |
| 74 | + | |
41 | 75 | | |
42 | 76 | | |
43 | 77 | | |
| |||
0 commit comments