Giter Club home page Giter Club logo

Comments (8)

SelenIT avatar SelenIT commented on July 17, 2024 3

@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.

Afif13 avatar Afif13 commented on July 17, 2024 2

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.

romainmenke avatar romainmenke commented on July 17, 2024 2

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.

SelenIT avatar SelenIT commented on July 17, 2024 1

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.

SelenIT avatar SelenIT commented on July 17, 2024 1

@myfonj yes, --prop gets resolved to 1 with :where() in Safari (both stable 17.4.1 and TP194).

from csswg-drafts.

bramus avatar bramus commented on July 17, 2024 1

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.

mayank99 avatar mayank99 commented on July 17, 2024

What if it resolves to :scope?

I believe :scope itself resolves to :root when used outside a @scope.

from csswg-drafts.

myfonj avatar myfonj commented on July 17, 2024

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 :wheres 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.