-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Reinstate <style scoped> #4508
Comments
Hi @wolfbeast, thanks for your interest. You'll want to familiarize yourself with https://whatwg.org/working-mode, and in particular https://whatwg.org/working-mode#additions. In particular, adding things to the spec does not magically make them appear in browsers; we are dependent on implementer interest to advance additions. We remove things from the spec when there are not two implementers supporting them, which was the case with scoped styles. We can leave this open as a "needs implementer interest" feature request, but I just want to be clear that the editors don't consider this feature of our process a "mistake", and we can't "undo" it without violating our working mode. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Unfortunately this thread is no longer on topic for the whatwg/html repository. If people would like to discuss the WHATWG working mode, then whatwg/sg is the right place to do so; that is where our policies are maintained and set. I'll mark the above comments as off-topic, but if folks continue to discuss things other than adding a new scoped styles feature, I'll have to lock this thread :(. |
I'll re-post what is relevant but what was marked off-topic.
Correction: that would be one of four (ours, Goanna*). I've also asked Mozilla to re-evaluate this for Gecko/Stylo. Bug 1542645 - Implement <style scoped> (again) (In case you are not yet familiar with it, Goanna is a Gecko fork at the basis of UXP which is a multi-application platform for XUL-based applications. Yes, it is a hard fork with its own development and implementations, not a "near-Gecko" variant.) |
Proponents of |
Not a bad idea, I suppose. Any idea how to proceed on that front like specific contacts? |
One of the issues |
@heycam is who implemented it originally, maybe he has more input. I don't think I'd personally have time right now to spend in writing a spec for In general, I don't think the feature is terribly hard to spec. I'm a bit concerned about implementation complexity (a big part of the reasons we removed it is that we were rewriting the style engine, and re-implementing |
Yeah, it seems like we should first fix all those scoping issues before re-introducing |
@emilio w3c/csswg-drafts#1995 is the issue tracking this problem for CSS references. Ryosuke recently commented again on it, and I just responded; would you mind putting an eye on it as well? |
This project is living in the future: https://github.com/gnat/css-scope-inline Keep the syntax simple and short, friends. I want to see |
As an implementation note: While we've worked on keeping a lot of parity with other browsers and removing dropped specs, we've made it a point of exception to retain I think we should aim to keep things straightforward for web content for a feature that has a ton of obvious utility for the web. @gnat: Interesting polyfill; creative workaround for sure! |
With CSS
<wrapper>
<style>
@scope {
:scope {
color: green;
}
}
</style>
<p>I am green!</p>
</wrapper> <wrapper>
<style scoped>
:scope {
color: green;
}
</style>
<p>I am green!</p>
</wrapper> /ping @mirisuzanne since we chatted about this. |
Related plug from CSS WG: simple <wrapper style="
& > p:first-child {
color: green;
}
& > p:last-child {
color: red;
}
">
<p>I am green!</p>
<p>I am red!</p>
</wrapper> At this point is unclear to me whether "scope-escaping" constructs like |
@myfonj Nesting in inline styles is very much planned, but technically harder to implement so we deferred it for later. |
I think part of the point of scoped styling being wanted where more sophisticated WebComponents could be used may simply be to some is like ordering a raid 10 NAS when all you need is a flash drive. The other bit is the nested style tag keeps the markup tidy where inline style attrs of any complexity are a mess (and that draft cited above would make that worse by normalizing it) While this may not be much of a consideration with high level frameworks and the vast and diverse landscape of javascript libs that make them up.. It is when you are just well.. making a website or writing the software to make a website and need some one off styling that is more than a one liner. I still believe the best solution is to have I dunno, maybe thinking about it like that will offer some insight. |
The issue with |
Right, authors can decide when they're ready to switch, but it's possible to polyfill (and hide from legacy browsers) using the |
Yeah, I'd like to suggest that we should probably close this as "done". It isn't done in exactly the same way, but better. |
Random thought/idea: I wonder if we could bring the <style type="scoped">
:scope { … }
</style> Instead of using an attribute, use a new Right now, the |
Not suggesting to close things here, but suggesting to add That way things like frameworks/CMSes can simply output the custom CSS in the |
The issue isn't legacy user agents at this point, the issue is that most of the current user agents have dropped it and treat it as such at the moment. That is, however, no different of a situation where new features are being introduced all the time. User agents can treat
I fully agree with this. Frameworks/CMSes have the option to spit out whichever CSS is necessary or desired based on browser detection (a common practice), and reintroducing it in the original implementation would also allow light-weight/scriptless and non-framework use of scoped styling without having to deal with completely over-engineered shadow-DOM solutions that are very difficult to implement properly for simple style separations in a page (and regularly don't even provide exactly what a web designer wants). |
@wolfbeast I do not believe you will win arguments or prove your point by calling web components "over-engineered" when you produce a XUL/XBL application platform and browser. Kinda stretches credibility ;) Unless something significant changes I will just add one more thing for now: HTML Templates were rolled into WebComponents even though they kind of predate them or at least was considered separate originally. Cramming complex style rules into a tag's style attr is just messy as much as a super long JSON structure in an attr is. What I believe makes WebComponents seemingly daunting is it isn't just one concept like most of html has been but several packaged together as a single huge game changing concept. Even though I am slightly familiar with Mozilla XBL, picking up WebComponents concepts at least at this early stage I am at has not been a walk in the park. This is a source of frustration my esteemed former colleague is letting slip through and others including my self feel because not everyone is the reach for whatever the popular framework is for everything type. Like I said, that's all I have really left to say on the matter unless there is a significant change. |
@mattatobin What projects and technologies I am otherwise involved in is completely irrelevant to the discussion here. The over-engineered nature of WebComponents is self-evident. |
I've read through the discussion in #552 and I'd like to ask that you reconsider your stance on removing this from the spec. There are many use cases for scoped styles that allow pure-HTML+CSS solutions in favor of a much more restrictive Shadow DOM and/or Web Components approach, let alone the involved complexity for web authors dealing with SD.
The only reason I see that this was scrapped from the spec was because Google refused to do the work and implement it, with nothing more than some vague excuses while playing favorites for SD. Considering Edge -> Chromium is now a thing, it's basically removing a good feature in the standard because of one implementer not wanting to implement it. The general responses on #552 also clearly voted against it -- this is the kind of feedback you should be listening to because those (people actually reading discussions on github for spec changes) are the people actively working with your specs.
Of note is that these approaches are not mutually exclusive or one being better than the other -- Different use cases would call for different approaches. They have overlap, there was also talk of revisiting this kind of styling question because there is a clear need for scoped styles on the web (and in the wild) that are currently using polyfills and workarounds to achieve, while we already had a proper solution for this in
<style scoped>
.FTR: Our projects building on UXP intend to keep this implementation despite it being scrapped from the spec, considering it is, in our opinion, a mistake that it was removed to begin with.
The need for this feature has not changed or diminished since 2016. Please consider undoing this mistake in the spec and reinstated scoped styling.
The text was updated successfully, but these errors were encountered: