Re: Opera's Proposal for :context Selector

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
modifier:

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

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 
selectors.

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 
tree.
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.

http://terrainformatica.com

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