-
Notifications
You must be signed in to change notification settings - Fork 693
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-cascade] Provide an attribute for assigning a <link> to a cascade layer #5853
Comments
I suspect that's not going to work, as existing user agents would just ignore the layer attribute, and assign all those styles to the default layer instead, so that's not going to be forward compatible. For <style layer="reset">
audio[controls] { display: block; }
</style> you can also do <style>
@layer reset {
audio[controls] { display: block; }
}
</style> For |
The CSS Working Group just discussed The full IRC log of that discussion<myles> Topic: Providing an attribute for providing a link to a cascade layer<astearns> github: https://github.com//issues/5853 <myles> miriam: This might need to to HTML. <argyle> https://www.irccloud.com/pastebin/zWOYuXvD/ <argyle> oh! full snippets!? <myles> miriam: The idea is if we're able to import into a layer in a stylesheet, shoudl be able to do this from a link to a stylesheet? Like an attribute. But there are issues. Attributes are usually ignored if the browser doesn't support them. Then you'd get a different fallback behavior than if the browser ignored a layer block <myles> florian: I dont' think that syntax can work. Doing it from HTML seems valid. but it probably couldn't be <missed> it would have to be something else because of fallback .Maybe rel="layer" <myles> florian: other than that, sure, why not <myles> fremy: there's an attribute for media <myles> fremy: we can maybe use it in have a special syntax: media="layer=..." <myles> fremy: I dunno,t hat was a random thought. IN browsers which don't support layer, it would never match because this media doesn't exist <myles> astearns: I'm not a fan of nesting it in media= <myles> florian: It would be ugly but it would work. <myles> astearns: For my clarification: florian, the layer attribute would not work, but just not in a link element, or also not in a style element <myles> florian: if you have <link> that loads a stylesheet that's ordinary in every respect except it also has a layer attribute, it wouldn't work because browsers would do a normal import, which isn't compatible behavior. <myles> astearns: So it would also be a problem in <style> <myles> miriam: The <style> doesn't need this because you can just put a layer inside of it easily. <myles> fantasai: We should table this until we have a specific proposal <myles> florian: Or push to WHATWG <bkardell_> you could <style>@import ... right? <myles> TabAtkins: let's open an issue on WHATWG. <tantek> sounds reasonable <myles> TabAtkins: Mabye we can stash it in media= like fremy said. They can think about it in WHATWG <myles> astearns: ok. <fantasai> +1 bkardell_, this might not be worth solving in HTML |
I would suggest |
The problem with that is that |
Might it be time to finally implement |
Without this, the only way to import 3rd-party styles from a CDN into a layer would be <link rel="stylesheet" href="https://example.com/framework.css">
<style>
@import url('https://example.com/framework.css');
</style> If so, we might want to revisit the priority of this? It seems like a fairly common use-case. |
@mirisuzanne These two should have the same performance (at least in Chromium). Both are captured by preload scanners. |
I think this is a problem worth solving, either by hacking a
The Chromium/WebKit preload scanner for CSS imports is significantly more fragile than its HTML equivalent, as it doesn't perform "real" tokenization. It'd be better to not put the weight of this feature's performance on it. Also, Firefox doesn't have such a preload scanner AFAIK. |
What is the next step for pushing a |
Little, I suspect. Next would be socializing it in WHATWG with an issue, getting some impl buy-in, and then writing a PR. |
2a2200e defines the production necessary for HTML to reference media & supports conditions as a single syntax. I think otherwise we can close this, and continue the conversation/progress in the linked WHATWG issue, and the HTML spec. |
I'm working on a PR against the HTML spec to allow support queries in That is to say, I think we might need to update CSSOM in order to make this possible? Would be glad for thoughts/advice (@tabatkins or @emilio, maybe?) on the best way to approach this. |
@frivoal what you mean with forward compatible? Having a link with |
@frivoal to your statement, there are npm addons like Material-UI that inject another thing is when I go over all the style tags every like @digitaldonkey said more options to set CSS chunks to layers will boost feature adoption. real and messy existing apps need more tools in their arsenal for unique problems. |
Florian's comment was not that we shouldn't do this, but that an attribute alone will cause compatibility issues - which is true. Any browser that doesn't understand the new This is something that we are actively working on for both |
Is this really such a problem though? The only people would would run into this problem, are the ones who choose to use the feature. I understand it is a problem that does need to be solved, but I don't see a reason it should completely hold up this feature. |
This problem was raised 5 years ago. If it had been specced and implemented at the time then we'd be able to use it now, instead worrying about backwards compatibility is causing a delay... Obviously developers could just wait until this feature has broad support before using it... |
This was raised on #4969, related to the Cascade level 5 spec.
We've defined a syntax for cascade layers to be declared as code-blocks or url imports:
If we're allowing authors to import entire stylesheets into a layer, it seems appropriate to make that available on
<link>
and<style>
tags as well. For performance reasons, those are more likely to be used - rather than chaining imports. I'm proposing alayer
attribute:The text was updated successfully, but these errors were encountered: