calebdwilliams / construct-style-sheets

Constructible style sheets/adopted style sheets polyfill
MIT License
142 stars 21 forks source link

Document.adoptedStyleSheets is no longer readonly #129

Open rmartine-ias opened 3 months ago

rmartine-ias commented 3 months ago

Document.adoptedStyleSheets is no longer readonly: https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets

In an earlier version of the specification, the array was not modifiable, so the only way to add new stylesheets was to assign a new array to adoptedStyleSheets.

This causes issues with newer typescript (I'm using 5.3) that is aware of this. For me, tsc --skipLibCheck false --incremental false was failing.

Here is the diff that solved my problem:

diff --git a/node_modules/construct-style-sheets-polyfill/dist/adoptedStyleSheets.d.ts b/node_modules/construct-style-sheets-polyfill/dist/adoptedStyleSheets.d.ts
index aa3d57a..c84a5e9 100644
--- a/node_modules/construct-style-sheets-polyfill/dist/adoptedStyleSheets.d.ts
+++ b/node_modules/construct-style-sheets-polyfill/dist/adoptedStyleSheets.d.ts
@@ -6,9 +6,9 @@ interface CSSStyleSheet {
 }

 interface Document {
-  adoptedStyleSheets: readonly CSSStyleSheet[];
+  adoptedStyleSheets: CSSStyleSheet[];
 }

 interface ShadowRoot {
-  adoptedStyleSheets: readonly CSSStyleSheet[];
+  adoptedStyleSheets: CSSStyleSheet[];
 }

This issue body was partially generated by patch-package.