Re: CSS Hierarchies / Selector Nesting Proposal

-----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>
</div>

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

http://terrainformatica.com 

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