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

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

From: Jonas Sicking <jonas@sicking.cc>
Date: Thu, 20 Oct 2011 02:35:10 -0700
Message-ID: <CA+c2ei9vb+4ANMy0MVggzMSYVLZK7TLDQOg-M9JaPS7FGspUEQ@mail.gmail.com>
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Ojan Vafai <ojan@chromium.org>, 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>
On Thu, Oct 20, 2011 at 2:13 AM, Lachlan Hunt <lachlan.hunt@lachy.id.au> wrote:
> On 2011-10-20 07:52, Jonas Sicking wrote:
>>
>> I'm not sure I understand what you are proposing here. Are you saying that
>>
>> <div>
>> <style scoped>
>> :scope {
>>   background: green;
>> }
>> </style>
>> </div>
>>
>> should set the background of the<div>  green? This does seem intuitive
>> I agree, but it might also lead to strange behavior since the
>> rendering of the<div>  will change once the stylesheet is parsed. In
>> other words, it's very easy to get flash-of-unstyled-content behavior.
>
> In the majority of cases, that's a very easy problem for authors to avoid by
> always putting <style scoped> as the first child of the element.  Since a
> <div> is invisible in most cases without any content or other styles, any
> change in rendering from invisible to visible wouldn't be any different from
> normal incremental rendering.

You'd also get the same effect since earlier siblings of the <style
scoped> would be affected, right?

I.e. in the following markup, both <span>s would be blue and the <div>
would be green.
<div>
<span>text here</span>
<style scoped>
:scope span { background: green }
:scope { background: red }
</style>
<span>more text here</span>
</div>

Another problem though is one of performance. Allowing <style>
elements which are "later" in the DOM affect earlier nodes means that
you have to walk significantly more nodes to look for which sheet
could apply. You'll have to both look at the elements children, as
well as all following siblings.

If <style scoped> elements only affect nodes which are later in DOM
order, it's much easier to keep a list of all currently applying
<style scoped> elements as you walk through the DOM tree.

However it's possible that this can be optimized satisfactory. But
it's something that we need implementation feedback on.

/ Jonas
Received on Thursday, 20 October 2011 09:36:15 GMT

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