-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
using refs in css #693
Comments
What about this? <style>
ref:container {
color: red
}
</style>
<div ref:container></div> It's valid CSS so shouldn't present any problems with parsing/syntax highlighting etc (csstree thinks it's a Probably best to avoid |
This would solve my use case, but one potential problem I could see with others is being explicit about how it fits into existing CSS rules. Who would win in this example? <style>
ref:container .child {
color: blue;
}
#id .child {
color: red;
}
</style>
<div id="id" ref:container>
<div class="child"></div>
</div> Under the hood were you thinking it would get a |
Good point. I think it probably makes sense if If it was implemented with a <div ref:container class='foo'>
this text would be red
</div>
<style>
.foo {
color: red;
}
ref:container {
color: blue;
}
</style> Turns out class and attribute selectors have the same specificity, so we could implement this with attributes or class names (and change our mind later, crucially) without breaking anything. |
Could maybe use the ref id instead of an index as suffix to the svelte component id. svelte-123abc-container |
This is implemented in 1.28 — thanks for the great idea |
When I use a ref, I most often also want to get a handle to it with css, which leads to slightly annoying, duplicative markup.
The only solutions I can think of to mitigate this are untenable, but thought I raise this if others see something better.
<div ref:class:container ></div>
The text was updated successfully, but these errors were encountered: