-
Notifications
You must be signed in to change notification settings - Fork 672
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
[css-scoping] scoped attribute on style element removed from HTML #137
Comments
It's likely to be dead; I suspect that we should remove it from the Scoping draft. It looks like, at least for now, browsers are settling on shadow DOM as the sole scoping mechanism. (While being somewhat more complex to use, it is much more powerful and feature-ful; |
Thanks for the information, though it is sad to hear. Shadow DOM may be more powerful, but requires JavaScript, which makes it less reliable or unusable in some contexts. Shadow DOM encapsulates code in two directions, i.e. styles in the shadow tree don’t affect outside markup and outside styles don’t affect shadow markup.
I understand that Compared to using a container ID in every rule, Nesting is a headline feature of CSS pre-processors like Less [1] and Sass [2] and CSS-Crush [3]. I think that shows that nesting capabilities are a desired and useful feature which [1] http://lesscss.org/features/#features-overview-feature-nested-rules |
CSS Nesting (that preprocessors do) has nothing to do with I recognize the benefits of scoping; they're minor but real. But browsers have not considered them worthwhile in the form of |
Yes, I fully agree that removing things from the spec that aren’t going to be implemented is the right thing to do. I didn’t mean to suggest anything else. I have difficulties to understand why Less:
Scoped CSS:
CSS:
Now that you’ve said it, I have found the css-nesting draft which does offer some useful features. Using it, the same code as above would look like this, if I’m not mistaken: Nested CSS:
It looks quite similar to the Less code, maybe even more so than the scoped code, but due to the
and encapsulate the whole code without modifications by nesting/scoping it with a container element’s ID. Less:
Scoped CSS:
So, in this case, I’d say that the pre-processor’s nesting has more to do with css-scoping than with css-nesting. |
I'm sad to see this discussion. I've been excited by this spec, and it does seem to have progressed since I last checked about a year ago (no more dependence on the HTML attribute, for one). I disagree that @scope is akin to just adding an id. Because of the way scope works in the cascade, nested scopes can do so much more than just ids. With normal id selectors, you would have to write every possible permutation to make them target correctly when nested, whereas styles from the innermost scope will inherently apply over the outer scope. This would be hugely valuable in highly-modular webapps. It seems to me this is the most direct answer to Christopher Chedeaux and all the CSS-in-JS discussion. |
To really drive home the point, consider three selectors inside of three scopes:
To get equivalent cascading behavior out of IDs, you need to take every permutation of every scope's id, and add that to every selector in that scope. Here is the equivalent of just scope
Then repeat ALL of that again for each of the other two scopes. Every time you add a selector to a scope, or add a new scope to the stylesheet, you exponentially increase the number of selectors you need everywhere.
|
Yes, I understand the benefits of scoped styles over just using an ID. But that doesn't change the calculus; browsers didn't end up accepting scoped styles in the form of |
This is really going past the demand. People are using Wordpress and non-wellformed-non-valid div-soup day to day. ShadowDOM is really great but a solution that works for regular DOM/HTML without a preprocessor and not only ShadowDOM is the way to go. ReactJS' and Elms adoption is also picking up. Unless you want another dead 'standard' as going for only ShadowDOM won't be adopted by masses. Also see: #270 |
This seems to be related, also: https://github.com/css-modules/css-modules |
If scope is being removed, is there another way to include styles as part of your module(s) that is nested in the body tag without breaking w3c standards? |
@unilobo |
ok, just when validating I get the following error: Error: Element style not allowed as child of element div in this context. (Suppressing further errors from this subtree.)
But as you say the latest spec states that it can be used In the body, where flow content is expected. i.e. most html tags |
I think you could file a bug at https://github.com/validator/validator/issues . Not sure if they are going to fix this as long as WHATWG's version of HTML forbids style in body. See the related issue there: whatwg/html#1605 |
@tabatkins I had some thoughts about this here: |
My only goal is to export a I guess it is possible to accomplish this with flat HTML, with large amounts of data redundancy; namely, generating a sufficiently long hash to put in the root element's |
https://drafts.csswg.org/css-scoping/#scoping-markup names the
scoped
attribute on HTML’s<style>
element as example for scoping markup and references the WHATWG HTML spec, but the attribute has been removed from HTML in both WHATWG’s and W3C’s version.whatwg/html#552
w3c/html#231
On a side note, is there hope that the very useful
@scope
CSS rule will be implemented by browsers or is scoping completely dead?The text was updated successfully, but these errors were encountered: