W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Re: QSA, the problem with ":scope", and naming

From: Roland Steiner <rolandsteiner@google.com>
Date: Thu, 20 Oct 2011 17:06:12 +0900
Message-ID: <CACFPSph=p4p1o5ZkjM2Fz+WCdaB5newZtg0nSMW9ccg_GYfoiQ@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Ojan Vafai <ojan@chromium.org>, Jonas Sicking <jonas@sicking.cc>, Alex Russell <slightlyoff@google.com>, Webapps WG <public-webapps@w3.org>, Yehuda Katz <wycats@gmail.com>, John Resig <jeresig@gmail.com>, Paul Irish <paulirish@google.com>, Lachlan Hunt <lachlan.hunt@lachy.id.au>
On Thu, Oct 20, 2011 at 14:08, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> <style scoped> should (I think) have three cases:
>
> 1. Selector without :scope - same as .find
> 2. Selector with :scope - Same as #1, but also including the context node.
> 3. Selector in @global - run the selector across the entire document,
> filter the results to only be the context node and its descendants.
>
> (Some people disagree with me on this, and think that #1 and #2 should
> be merged to always include the context node.  That's acceptable, but
> I don't like it as much.)
>

The - very valid IMHO - main argument for <style scoped> to always include
the scoping element was to allow for easy migration. I.e., where currently
you'd use

<style>
    #menu .foo { color: green }
</style>

<div id="menu">
    <div class=foo>
        Will be green
    </div>
</div>
<div class=foo>
    Will NOT be green
</div>

You could just stick the stylesheet under the div and add 'scoped':

<div id="menu">
    <style scoped>
        #menu .foo { color: green }
    </style>
    <div class=foo>
        Will be green
    </div>
</div>
<div class=foo>
    Will NOT be green
</div>

In browsers that don't support 'scoped', this would still work. Where
'scoped' is supported, this doesn't change much per se, except that those
style rules don't need to be checked outside the scope. Once a majority of
browsers support <style scoped> one can then proceed to simplify the rules
and remove '#menu' (admitted caveat: where this then doesn't create an
ambiguity with the scoping <div>).


- Roland
Received on Thursday, 20 October 2011 08:06:58 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:48 GMT