[whatwg] Selectors within <style scoped>

Lachlan Hunt lachlan.hunt at lachy.id.au
Fri Jun 17 04:46:48 PDT 2011


On 2011-06-17 09:36, Roland Steiner wrote:
> On Fri, Jun 17, 2011 at 4:10 PM, Roland Steiner<rolandsteiner at google.com>wrote:
>> http://dev.w3.org/2006/webapi/selectors-api2/#the-scope-pseudo-class says:
>>
>> The :scope<http://dev.w3.org/2006/webapi/selectors-api2/#scope>
>>   pseudo-class *must* match any element that is a contextual reference
>> element<http://dev.w3.org/2006/webapi/selectors-api2/#contextual-reference-element>.
>>
>> so :scope is ambiguous if you have several scoping elements as ancestors.
>> :scope in a nested sheet, meant to limit the rule to the nested scoping
>> element, may instead match against an enclosing scoping element. Again, see
>> the example I mailed earlier.
>>
>
> Actually, re-reading that section I think I misunderstood the meaning. If
> only the direct parent of a<style scoped>  is considered a contextual
> reference element for rules in _that_ style-sheet (rather than an element
> being a contextual reference element for _some_ scoped stylesheet), there is
> no ambiguity.

That is correct. However, note that the definition of :scope itself does 
not define which elements are the contextual reference elements (except 
where it defaults to the document root element) and it can it theory 
support more than one [1].  But it is up to the specification defining a 
particular context to define what the contextual reference elements are, 
and HTML5 needs to define that the contextual reference element for a 
given scoped stylesheet is its parent element.

[1] In fact, the refNodes parameter of the querySelector* methods
     explicitly allows there to be more than one in that context.

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/



More information about the whatwg mailing list