Comments (8)
@Afif13 I just tested in Safari 17.4.1, it increases specificity for each &
(&&
overrides &
that comes later). Safari TP 193 does the same.
from csswg-drafts.
Just in time when I am sharing another quirk around "&": https://twitter.com/ChallengesCss/status/1787931976663466068
&& {
/* will select the html element */
}
&&&& {
/* will also select the html element */
}
&&&&&&& {
/* I think you get the idea */
}
/* All the above have the same specificity */
I suppose Safari will make all the above having a different specificity? Can you test it please? I cannot.
from csswg-drafts.
I actually find it surprising that &
at the root does not always have the same specificity as :scope
.
I would also expect &&
at the root to have the same specificity as :scope:scope
.
from csswg-drafts.
Currently the spec says that
The specificity of the nesting selector is equal to the largest specificity among the complex selectors in the parent style rule’s selector list (identical to the behavior of :is()).
As I read the current spec, &
as the top level selector represents the same thing as :scope
in the same context (i.e. :root
) but has the specificity identical to that of :is()
with the empty selector list (i.e. zero). So behavior of Chrome and Firefox looks intuitive to me and behavior of Safari (presuming it does some implicit conversion/substitution) seems too "magical". However, adding an explicit clarification about that particular case would be great!
from csswg-drafts.
@myfonj yes, --prop
gets resolved to 1
with :where()
in Safari (both stable 17.4.1 and TP194).
from csswg-drafts.
I believe this is covered by #10196 (comment)
RESOLVED: explicitly state in specs that when an ampersand doesn't actually have a parent rule to draw from then its specificity is zero
Closing.
from csswg-drafts.
What if it resolves to :scope
?
I believe :scope
itself resolves to :root
when used outside a @scope
.
from csswg-drafts.
For me the "root specificity exception" (i.e. that root-level &
targeting :scope
has zero selector specificity, like in current Firefox and Chrome) makes also sense, but I understand that it seems like an extra hatch maybe.
Intuitively I'd expect that when I fold everything I have so far in a style with one or more &
s it should not change "much", i.e. in.
<style>
& { & { body { --prop: 3; } } }
& { body { --prop: 2; } }
body { --prop: 1; }
</style>
I'd expect to --prop
to be still 1
.
I see that it might be inconsistent with non-root &
behaviour and explicit :where
s would be required here to make it weak again, thus uniform with &
's general behaviour. I guess in
<style>
:where(&) { :where(&) { body { --prop: 3; } } }
:where(&) { body { --prop: 2; } }
body { --prop: 1; }
</style>
--prop
gets resolved to 1
even in Safari right now? (Cannot test.)
This also maybe raises a question for #8752 , whether <el style="--prop: …;">
and <el style="& { --prop: …; }">
should make any difference or not.
from csswg-drafts.
Related Issues (20)
- [css-mixins] Disallow whitespace when matching `'<' transform-list '>'` HOT 2
- [css-mixins] Should `result` be mandatory in `@function`? HOT 1
- [css-filter-effects-1] Missing definition of a reference for percentage values if filterUnits="userSpaceOnUse" HOT 3
- [css-fonts] Font fallback for (Unicode) decomposable characters is browser-dependent HOT 1
- [selectors] Parameterized selectors HOT 16
- [css-view-transitions-2] (feature) access view-transition snapshot as an image/ImageData HOT 8
- [scroll-animations] Allow smooth animation from lvh to svh
- [web-animations] how to make animate() method work with CSSKeyframesRule object? HOT 4
- [css-color-5]: Relative Colors doesn’t work with `calc(l + 10%)` HOT 1
- [css-color-5]: light-dark() doesn’t work with Relative Colors HOT 2
- Two "variants" of `color-mix()` ?? HOT 4
- [css-animations-2][web-animations-2] (proposal) Add pointer driven animations
- [css-values-5] Should `interpolate-size` be a new value to animation/transition-behavior? HOT 6
- CSS Color; light-dark() should be applicable on more properties. HOT 6
- [css-color-4] Evaluate static gamut mapping algorithms for oklab/oklch spaces HOT 3
- [css-easing-2] Linear easing function requires at least two points?
- [scroll-animations-1] Consider adding a timeline range that takes ink overflow into account
- [scroll-animations-1][css-animations-1] A non-animated "Is in viewport"
- [css-ui-4] Add `outline-offset-(inline|block)[-(start|end)]`
- [css-view-transitions-2] Capture modes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csswg-drafts.