construct-style-sheets icon indicating copy to clipboard operation
construct-style-sheets copied to clipboard

Document.adoptedStyleSheets is no longer readonly

Open rmartine-ias opened this issue 8 months ago • 0 comments

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.

rmartine-ias avatar Jun 11 '24 20:06 rmartine-ias