Skip to content

Commit

Permalink
Make ShadowRoot stylesheet list work only when the shadow root is con…
Browse files Browse the repository at this point in the history
…nected.

This avoids the issue of triggering stylesheet loads for disconnected stuff and
such, and is more consistent with Chrome and WebKit.

This is per the recent CSSWG resolution at
w3c/csswg-drafts#3096.

Differential Revision: https://phabricator.services.mozilla.com/D5699

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1490791
gecko-commit: 71f86120ca35d113a2462b2ffe68bc5accc813e4
gecko-integration-branch: autoland
gecko-reviewers: smaug
  • Loading branch information
emilio authored and moz-wptsync-bot committed Sep 13, 2018
1 parent 632a3f5 commit 8d57f38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 3 additions & 1 deletion shadow-dom/ShadowRoot-interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@
var host = document.createElement('div');
var shadowRoot = host.attachShadow({'mode': mode});

assert_equals(shadowRoot.styleSheets.length, 0, 'shadowRoot.styleSheets must be empty when the shadow root does not contain any stylesheets');
shadowRoot.innerHTML = '<span></span><style> a.rule {} </style><style> b.rule {} </style>';
assert_equals(shadowRoot.styleSheets.length, 0, 'shadowRoot.styleSheets must be empty when the shadow root is not connected');

document.body.appendChild(host);
assert_equals(shadowRoot.styleSheets.length, 2, 'shadowRoot.styleSheets must contain two items when the shadow root has two style elements');
var styles = shadowRoot.querySelectorAll('style');
assert_equals(shadowRoot.styleSheets[0], styles[0].sheet, 'shadowRoot.styleSheets[0] must be the first style element in the shadow root');
Expand Down
6 changes: 1 addition & 5 deletions shadow-dom/untriaged/styles/test-003.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
assert_equals(s.styleSheets.length, 0, 'There should be no style sheets');
}), 'A_06_00_03_T02');

//TODO Now this tests produces an error on Chromium because styleSheets.length
//returns 0 when the shadow root is orphaned.
//Tracking bug: http://crbug.com/392771
test(unit(function (ctx) {
var d = newRenderedHTMLDocument(ctx);
var host = d.createElement('div');
Expand All @@ -60,8 +57,7 @@
style.textContent = 'div {width: 50%;}';
s.appendChild(style);

// The following line fixes the issue on Chromium, http://crbug.com/392771
// d.body.appendChild(host);
d.body.appendChild(host);
assert_equals(s.styleSheets.length, 1, 'Style sheet is not accessible via styleSheets');
}), 'A_06_00_03_T03');
</script>
Expand Down

0 comments on commit 8d57f38

Please sign in to comment.