Skip to content

Commit

Permalink
Fix "update a style block" early return
Browse files Browse the repository at this point in the history
The new version matches implementation reality and CSSWG resolution.

The algorithm was also inconsistent, as it looked at whether
the element was in a shadow tree or in the document tree, but it was
only specified to be re-run if the element becomes connected or
disconnected.

The CSSWG discussed this in
w3c/csswg-drafts#3096 (comment)
and http://wpt.live/shadow-dom/ShadowRoot-interface.html tests this.

This also matches closer the definition of <link rel="stylesheet">,
which does use connectedness (though it uses "browsing-context
connected", which is a bit different):
https://html.spec.whatwg.org/#link-type-stylesheet
  • Loading branch information
emilio authored Jan 25, 2021
1 parent 31b3458 commit 0f26153
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -15102,11 +15102,10 @@ interface <dfn>HTMLStyleElement</dfn> : <span>HTMLElement</span> {
<li><p>If <var>element</var> has an <span>associated CSS style sheet</span>, <span
data-x="remove a CSS style sheet">remove the CSS style sheet</span> in question.</p></li>

<li><p>If <var>element</var>'s <span>root</span> is neither a <span>shadow root</span> nor a
<span>document</span>, then return.</p></li>
<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2740
Also, per https://github.com/w3c/webcomponents/issues/56 stylesheets should work in
disconnected shadow trees. -->
<li><p>If <var>element</var> is not <span>connected</span>, then return.</p></li>
<!-- See:
https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2740
https://github.com/w3c/csswg-drafts/issues/3096 -->

<li>
<p>If <var>element</var>'s <code data-x="attr-style-type">type</code> attribute is present and
Expand Down

0 comments on commit 0f26153

Please sign in to comment.