[whatwg] Selectors within <style scoped>

Ashley Sheridan ash at ashleysheridan.co.uk
Wed Jul 20 12:55:51 PDT 2011

On Wed, 2011-07-20 at 20:36 +0100, Kornel Lesiński wrote:

> On Tue, 19 Jul 2011 05:14:55 +0100, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> > This is actually an interesting question.  Does this end up  
> > corresponding to:
> >
> >    :scope foo .bar, foo:scope .bar
> >
> > or to just
> >
> >    :scope foo .bar
> >
> > ?  The latter would not match on 'foo' being the scope element, while  
> > the former would.
> I think it should match the scoping element, as I expect this pattern to  
> be common until <style scoped> is widely supported:
> <div id=widget>
>    <style scoped>
>      #widget foo {}
>    </style>
> </div>

While I agree that that might be a common pattern, I disagree that it's
actually a good one. Consider an ad service which wraps everything in a
custom <div> tag. If the scope allowed the immediate parent to be
included as part of the scope, then it could allow the advert to be
altered in a way that could negatively affect the users of the site the
ad appeared on.

The purpose of scope in the style seems to be to protect elements
outside of the included content and to 'contain' the included content
that has the <style scoped> element in it, presumably because it's
coming from an external source. If you allowed the immediate parent as
your example, then it could allow the 3rd parties who created the advert
to take over the element beyond what the advert service would prefer to
be allowed.


More information about the whatwg mailing list