-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix update a style block to match reality and CSSWG resolution. #6294
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I would appreciate an @annevk double-check.
The way I understand the discussion linked here the conclusion was for the stylesheet to be parsed but not have any imports execute until the node is being connected. |
That sounds about right, but:
So for what you want, I think constructable stylesheets is what solves your use case. Having |
I don't feel like Apart from not knowing what the future holds for constructable stylesheets in regards to adoption and subsequent API stability I don't really feel like it's a good fit for my use case. What I need is instance level programmatic control over pseudo classes; and while I could construct a stylesheet on a per instance basis using bespoken API and "adopt" it into the shadowroot, it seems to be quite redundant considering I'm having a The current workaround is to cache the values in member variables or custom attributes and then sync them in the I feel like the status quo shouldn't really affect the decision on this but let me ask you this: if I were to do a PR on a major browser implementing bespoken behavior would that change your stance on it? |
That's not how styles work outside of shadow DOM, so it doesn't seem all that sensible to me. How is The reason why I filed w3c/csswg-drafts#3096 to begin with is because browsers were doing super-weird stuff when I was implementing Shadow DOM v1 in Firefox.
Can you show some code so I can take a look at what you're doing? Browsers try very hard to share
Well, I don't think so. This is not just a matter of my stance, there's a working group resolution on the behavior on w3c/csswg-drafts#3096. You can file an issue to reconsider that resolution of course, but meanwhile there's no reason to have the HTML spec say something that is self-inconsistent, that nobody implements, and that goes against a CSSWG resolution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still a difference, right? <link>
uses browsing-context connected, this does not. See also #4547. Aligning them fully would be ideal I think.
(Also, @rniwa commented on this previously in #1137, which led to #1194 and #1199, but I guess that never got implemented. I suspect at the time the rationale for trying to make this work was that if it worked for standalone documents it should work for standalone shadow roots, but in retrospect that's not that compelling.)
Ideally I'd like
I was using additional |
@emilio @annevk should we merge this, or is the remaining mismatch of connected vs. browsing-context connected worth changing something for? Also, I see http://wpt.live/shadow-dom/ShadowRoot-interface.html failing in Firefox; is that expected? Maybe we should add tests for connected-but-not-BC-connected, as well? |
@domenic it passes on Firefox Nightly, it was an edge case that I added a test for recently, see https://bugzilla.mozilla.org/show_bug.cgi?id=1687126. Firefox stable parses the stylesheet once connected, but wouldn't remove it if you removed the shadow host. |
I'm happy for this to be merged. |
No browser passed the test-case that was linked from the comment. 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 there are WPTs for 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
Great. I'd love to see some tests for connected but not BC-connected, but we don't need to block on that; I'll file a WPT issue. |
No browser passed the test-case that was linked from the comment.
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 there are WPTs for this.
This also matches closer the definition of which does
use connectedness (though it uses "browsing-context connected", which is a
bit different): https://html.spec.whatwg.org/#link-type-stylesheet
(See WHATWG Working Mode: Changes for more details.)
/semantics.html ( diff )