Re: Selector Sugar

From: "Brad Kemper" <brkemper.comcast@gmail.com>
>
>
> On Oct 9, 2008, at 8:53 AM, Tab Atkins Jr. wrote:
>
>> I want to talk about two issues of syntactic sugar that I believe  would 
>> be very useful to us authors.  [..........]
>>
>> (1) Scoped selectors within a stylesheet.
>>
>>  [.........]
>>
>> (2) Multi-matching selector
>>
>>  [.........]
>>
>> ~TJ
>
> I agree that those would be valuable. [........]
>
> I wonder if it might even be possible to leave out the @scoped, and  just 
> have it like this to do the same thing:
>
> #nav-menu {
> h1 {
> //This is equivalent to the selector "#nav-menu h1",
> //and so won't target <h1>s across the rest of the page.
> ...
> }
> ul {
> ...
> }
> more rules...
> } //end of scope

I agree with you but there's a problem :

    li.hoverLink {
        a:hover,
        a:focus {
            color: red;
         }
    }

The parser will think that 'a' is a property and 'hover,' a value, and that 
the property incorectly ended.
With another syntax, like an at-rule, it should delete this problem.

    li.hoverLink {
        @rule a:hover, a:focus {
             color: red;
        }
    }

The problem with this, is that we introduce the use of at-rules in the 
selectors, and it was not existing before.
Some old browers can think we have :

    li.hoverLink {
        // bad line
        color: red;
        // bad line
    }

So, as I prefer a 'not-friendly' solution (@scope and :any) than no solution 
at all, I agree to discuss this...
Fremy 

Received on Thursday, 9 October 2008 17:25:19 UTC