W3C home > Mailing lists > Public > www-style@w3.org > June 2011

Re: CSS Hierarchies / Selector Nesting Proposal

From: Andrew Fedoniouk <andrew.fedoniouk@live.com>
Date: Fri, 3 Jun 2011 09:38:13 -0700
Message-ID: <BLU165-ds100E5C267AABFAE758A820F87F0@phx.gbl>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "Brad Kemper" <brad.kemper@gmail.com>, "Boris Zbarsky" <bzbarsky@mit.edu>, <www-style@w3.org>
-----Original Message----- 
>From: Tab Atkins Jr.
>Sent: Friday, June 03, 2011 12:06 AM
>To: Andrew Fedoniouk
>Cc: Brad Kemper ; Boris Zbarsky ; www-style@w3.org
>Subject: Re: CSS Hierarchies / Selector Nesting Proposal
>On Thu, Jun 2, 2011 at 11:54 PM, Andrew Fedoniouk
><andrew.fedoniouk@live.com> wrote:
>> And yet I am not sure how SASS will be reflected in CSSOM. In general if 
>> you
>> have
>> something like this:
>> #foo {
>>  &>#bar {  ... }
>>  &>#ozo { ... }
>> }
>> you will want to delete all contained rules when you delete "master" rule
>> #foo.
>> The same about other manipulations like cloning, etc.
>> So what exactly that compound SASS style block is?
>> Is it just a preprocessor (pure parse time)  feature or is it rather a 
>> style
>> set - set of rules
>> that are applied on all-or-none basis?
>Also addressed in my initial email.  Within the CSSOM, nested rules
>are exposed from the .cssRules property on the outer rule, identically
>to how rules are exposed when nested inside of a @media rule.  So,
>yes, if you delete the outer rule via the CSSOM, you'll delete the
>nested rules as well.

Interesting. So in your model such a compound rule (the one having nested
sub-rules) is a block, well sort of.
It is being parsed to tree structure rather than to flat list of rules.
That is conceptually different from LESS or SASS processing model.

What would be specificity laws for rules in such a tree then?

Consider this DOM:

<div #foo .class-foo>
  <p #bar>.</p>

And these rules:

div#foo {
  & p {  ... } /* rule A */
  & a {  ... }

div.class-foo {
  & p#bar {  ... } /* rule B */
  & a {  ... }

As for me 'rule A' should have larger specificity than 'rule B'
because its "master selector" (div#foo) has larger specificty as
it is more concrete.

I suspect your mental model assumes something like that too. Yes/no?

Andrew Fedoniouk

Received on Friday, 3 June 2011 16:38:43 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:50:01 UTC