Skip to content

Commit

Permalink
Remove adopted stylesheets when adopting to a different document
Browse files Browse the repository at this point in the history
When adopting a subtree to a different document, we'll remove all the
adopted stylesheets in that subtree, instead of keeping them and then
ignoring them in style calculation.

Relevant discussion: WICG/construct-stylesheets#23

Bug: 807560
Change-Id: I7ea6c869892cabd9d3b5a765f26364e51b1419b4
Reviewed-on: https://chromium-review.googlesource.com/c/1415068
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623660}
  • Loading branch information
rakina authored and chromium-wpt-export-bot committed Jan 17, 2019
1 parent 0528148 commit 52006fa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions css/cssom/CSSStyleSheet-constructable.html
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,18 @@
span.shadowRoot.adoptedStyleSheets = [sheet];
assert_equals(getComputedStyle(shadowDiv).color, "rgb(255, 0, 0)");

document.adoptNode(span);
assert_equals(span.shadowRoot.adoptedStyleSheets.length, 1);
assert_equals(span.shadowRoot.adoptedStyleSheets[0], sheet);

const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.contentDocument.adoptNode(span);
iframe.contentDocument.body.appendChild(span);
assert_not_equals(span.shadowRoot, null);
assert_equals(span.shadowRoot.adoptedStyleSheets.length, 1);
assert_equals(span.shadowRoot.adoptedStyleSheets[0], sheet);
assert_equals(span.shadowRoot.adoptedStyleSheets.length, 0);
assert_equals(getComputedStyle(shadowDiv).color, "rgb(0, 0, 0)");
}, 'Adopting a shadow host will move adoptedStyleSheets but it is not applied');
}, 'Adopting a shadow host will empty adoptedStyleSheets if adopting to a different document');

</script>

0 comments on commit 52006fa

Please sign in to comment.