[whatwg] Selectors within <style scoped>
David Hyatt
hyatt at apple.com
Thu Jun 16 13:48:14 PDT 2011
Do you actually mean try out both ":scope" tacked on to the end of the rule as well as ":scope " (note the space indicating a descendant selector) tacked on to the beginning?
So for example, #foo { } would turn into #foo:scope, :scope #foo { } thus allowing it to match either the scope or a descendant of the scope?
This would also have the benefit of allowing you to cross if the rightmost selector in a chain is the scope without having to explicitly use :scope.
For example:
#outsideScope #insideScope { }
would turn into
#outsideScope #insideScope:scope, :scope #outsideScope #insideScope { }
thus allowing crossing for the case where #insideScope is the scope itself.
dave
(hyatt at apple.com)
On Jun 16, 2011, at 1:32 PM, Dimitri Glazkov wrote:
> What if we do this:
>
> 1) By default, <style scoped> implies that all selectors in this
> stylesheet are prefixed with ":scope".
> 2) Unless the ":scope" is already in the selector.
>
> :DG<
>
> On Thu, Jun 16, 2011 at 10:40 AM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
>> On Thu, Jun 16, 2011 at 10:28 AM, Dimitri Glazkov <dglazkov at chromium.org> wrote:
>>> But looking at this with my Web developer hat on, I would almost
>>> _always_ prefix scoped rules with :scope, just to be safe. I certainly
>>> don't want my ".closed .foo { display:none }" to start reacting to
>>> some doofus syndicating my code in the wrong way. I can see how this
>>> logic quickly downgrades ":scope" to syntactic shellack.
>>>
>>> I think we should ask how Web developers would view this. I am pretty
>>> sure that their intuitive understanding of <style scoped> is that all
>>> rules are implicitly prefixed with ":scope".
>>
>> As a web developer, I agree - my intuitive understanding of @scoped is
>> that it makes matching *start* at the scoped element. That's what
>> "scoped" means. The other meaning is more like a filter.
>>
>> I was convinced that @scoped worked exactly like this until this
>> thread. Apparently my previous reading of the spec was insufficiently
>> deep to spot the scoping/filtering difference.
>>
>> FWIW, I also think that querySelector got this wrong. It should have
>> scoped by default, and then possibly also offered an option to filter
>> based on an element.
>>
>> ~TJ
>>
More information about the whatwg
mailing list