Re: [cssom] CSSRule.parentRule and CSSRule.parentStyleSheet should return a "CSSRule?"

On Sun, Sep 2, 2012 at 3:46 PM, Daniel Glazman <> wrote:

> Le 01/09/12 03:41, Boris Zbarsky a écrit :
>  On 8/31/12 8:41 PM, Glenn Adams wrote:
>>> Please check. If CSSOM defined constructors for CSSRule concrete
>>> subclasses, then I could see this happening. But it doesn't at present,
>>> and I'm not sure it appropriate to spec if the spec doesn't otherwise
>>> define a context in which it could be null.
>> I think the issue here might be one of lifetime management. I believe
>> that if you're holding on to a rule and the rule's stylesheet is not
>> attached to a document and you're not holding on to the stylesheet
>> itself we will garbage-collect the stylesheet and null out the rule's
>> parentStyleSheet. Could be wrong, though.
> 1. get a CSS rule from the OM, keep it in a JS variable
> 2. find the owner node
> 3. delete it from DOM
> 4. parentStylesheet is then null

To elaborate further, if an HTMLStyleElement is removed from a Document,
then the HTMLStyleElement still exists and its ownerDocument attribute
still references the Document it was previously associated with. Similarly,
the HTMLStyleElement instance still implements LinkStyle, and still has a
style attribute that references a StyleSheet instance containing all the
rules it did prior to removing the element from the Document. If an
implementation behaves differently, it is broken.

The only affect on the CSSOM for removing the HTMLStyleElement from its
Document is that its style sheet should no longer appear in
document.styleSheets and document.{selected,last}StyleSheet and
document.styleSheetSets may be mutated.

Received on Sunday, 2 September 2012 11:50:30 UTC