Re: Enhancing grouping of selectors

----- Original Message -----
> On Friday 2010-09-17 15:18 -0700, Tab Atkins Jr. wrote:
> > I think the sanest solution is to use the min or max specifity of
> > the
> > contained argument, so either 003 or 300. Probably the latter.
> 
> I think the best solution for authors is to compute specificity
> based on which selectors actually matched (and use the highest).
> 
> That's just a little more work to implement, not because it's
> inherently more difficult than the current model, but rather because
> it requires more change to existing implementations in which
> specificity of selectors is computed before selector matching.
> 

I think you are right. So, using a cut down version of my previous example (I don't want to write 27 combinations!):

:any (e1, .class1, #id1) :any (e2, .class2, #id2) {....}

Should be equivalent to the following exploded version:

     e1 e2,      e1 .class2,      e1 #id2, 
.class1 e2, .class1 .class2, .class1 #id2,
   #id1 e2,    #id1 .class2,    #id1 #id2 {...}

The simplest approach seems to be to just explode it, you wouldn't get any performance benefit but that is not an issue if the purpose is to ease authoring. After all the exploded version is exactly what the author would have had to write anyway.

The above example is not exactly realistic, in terms of the real example you have in http://dbaron.org/log/20100424-any specificity is not really an issue as all selectors in each :-moz-any() have the same specificity. Therefore, you could add a special optimization to handle that to improve performance.

Received on Saturday, 18 September 2010 07:44:31 UTC