W3C home > Mailing lists > Public > www-style@w3.org > October 2012

Re: [cssom] Make CSSStyleSheet constructable

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 17 Oct 2012 20:33:36 -0400
Message-ID: <507F4E60.5040106@mit.edu>
To: www-style@w3.org
On 10/17/12 8:16 PM, Tab Atkins Jr. wrote:
> The "scoping" nature of a TreeScope is good for preventing stray
> styles from leaking out of the component, but it's problematic when
> you have, say, a thousand copies of the same component on the page,
> all of which contain their own, identical, copies of the same
> stylesheet.

This is an inline stylesheet, not a linked stylesheet?

> Our attempts to date have been somewhat hacky, unfortunately.

I'm not sure why.  Gecko already does such sharing on the style data of 
linked stylesheets.  It would be easy to extend it to inline stylesheets 
if needed.

> It seems like the best path to get this is to allow CSSStyleSheets to be
> directly constructed in JS, so that a single sheet can be added to the
> TreeScope#styleSheets list of multiple components.

I'm not sure why this is is the best path... Care to expand on that?

> The details seem reasonably simple.  It seems there are two cases for
> construction - constructing via URL, and constructing via stylesheet
> string.

Again, the URL case is already handled in Gecko.  And the other is not 
hard to handle.

The biggest problem with the non-URL case is whether you actually end up 
with lots of copies of the style data textnode in your DOM, right?

> Does this seem sane to other people?  Thoughts?

It seems to be pushing on to authors work that UAs can easily do under 
the hood, and that's useful for cases other than just components so UAs 
might as well just do it anyway...

-Boris
Received on Thursday, 18 October 2012 00:34:04 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:01 GMT