[whatwg] Selectors within <style scoped>

Tab Atkins Jr. jackalmage at gmail.com
Thu Jun 16 10:40:48 PDT 2011


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