W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Opera's Proposal for :context Selector

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Mon, 14 Jul 2008 14:52:58 -0700
Message-ID: <487BCABA.1050400@terrainformatica.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Joshua Cranmer <Pidgeot18@verizon.net>, Lachlan Hunt <lachlan.hunt@lachy.id.au>, www-style <www-style@w3.org>

Tab Atkins Jr. wrote:
> On Mon, Jul 14, 2008 at 4:17 PM, Joshua Cranmer <Pidgeot18@verizon.net> wrote:
>> Tab Atkins Jr. wrote:
>>> I agree here, though, that *without* a :scope or :context pseudoclass,
>>> it can be difficult to achieve proper modularity.  Frex, in this
>>> fragment:
>>> <section>
>>>  <style scoped>
>>>    div span { color: red }
>>>  </style>
>>>  <span>span content</span>
>>>  <div>
>>>    <span>some more span content</span>
>>>  </div>
>>> </section>
>>> The second span will definitely be red, but the first will be red
>>> depending on whether or not there is a div somewhere further up the
>>> ancestor chain.
>> This sounds as if it's a bug. As  developer, I would intuitively expect such
>> a document fragment to have the same results regardless of extra content.
>> Whether or not the section is wrapped in a div or not should not (IMHO)
>> affect the styles generated by the scoped stylesheets. I fail to see a
>> compelling use case that calls for the scoped stylesheets to be
>> knowledgeable of the existence of any elements outside the scoped root
>> (e.g., the section).
> Being able to do a query against the full document *is* useful, but
> you need some way to specify that you want a selector to *only* query
> against the elements in scope, or you get the unintuitive results that
> you mentioned.  That'd be the :scope/:context pseudoclass.
That will lead to requirement to prepend practically all style rules in 
scoped style sheet with the :context

      <style scoped>
        :context div span { color: red }
     <span>span content</span>
        <span>some more span content</span>

That implies that style systems inside <style scoped> and <style> shall 
use different CSS "vocabularies" or flaws.
This pretty much means that you cannot share your style declarations 
between standalone and embedded version
of your  <section>.  That also means that <style scoped> only implies of 
use of inline styles.
<style scoped src="..." /> will become a nonsense - you cannot reuse the 
same scoped style for different
sections even on the same page as they may contain position dependent 

If you do need global selectors use standard approach - put your styles 
in global scope. And they will work.
The beauty of scoped style sheets is in the fact that they are scoped 
per se -  can be applied to the scope
elements independently from positions of these scope elements in the DOM 
CSS simply does not allow you to do such independent isolation now.

And yet. Scope local lookups has computational complexity significantly 
less and independent from the
size of the tree of the master document. If such matters count of course.

Andrew Fedoniouk.

Received on Monday, 14 July 2008 21:53:48 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:38 UTC