capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.28k stars 200 forks source link

`document.styleSheets` don't react to `document.adoptedStyleSheets` changes #1458

Open aralroca opened 3 months ago

aralroca commented 3 months ago

Describe the bug

const sheet = new CSSStyleSheet();

sheet.insertRule("div { color: red; }");
document.adoptedStyleSheets = [sheet];

Modifies the document.styleSheets, but in the tests with happy-dom, this is not reflected.

To Reproduce

Just run:

const sheet = new CSSStyleSheet();

sheet.insertRule("div { color: red; }");
document.adoptedStyleSheets = [sheet];

expect(document.styleSheets).not.toBeEmpty()

Expected behavior

The document.styleSheets should be updated according the the changes with document.adoptedStyleSheets.