Skip to content

Document.adoptedStyleSheets is no longer readonlyΒ #129

@rmartine-ias

Description

@rmartine-ias

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions