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:
>   
>> 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.
>   
I don't see how it's useful--I would like a real-world-ish example. 
Also, agreeing with Andrew here, I think to not make scoped stylesheets 
only apply to a fragment defeats the purpose. To wit:

1. The effect of scoped stylesheets can be practically emulated as 
substituting ":context" (under your proposal) with an identifier for the 
scoped object. There is neither a save in stylesheet length nor a save 
in readability. The only possible use case I can imagine is when the 
author of the fragment has no control over the rest of page (e.g., web 
fora), for which the ability to include external factors in queries is 
questionable, as the conditions where the fragment is included is going 
to be either stable or totally unreliable.

2. A scoped stylesheet, to me, implies a document fragment. I think 
authors want to expect results to be reliable regardless of the location 
of the fragment. If the location does matter, then one should simply 
make the stylesheet not scoped.

3. It is more useful to have the queries start with only the elements in 
scope than to have it start from the root. Using your example, if the 
original CSS was wrapped in a div, then the results change dramatically.

4. AIUI, the purpose for scoped stylesheets is two-fold: to be used for 
sandboxed content, and to be specific to specific subsections carried 
across multiple mediums (e.g., styling for a blog entry that may be 
included in a feed). Querying globally, as I've stated repeatedly, is 
something that seems rather pointless.

5. Authors will better understand the usage of a scoped stylesheet to 
mean "in the document fragment" instead of "a set of queries that only 
apply to the document fragment."

-- 
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth

Received on Monday, 14 July 2008 22:22:01 UTC