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

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

From: Glenn Adams <glenn@skynav.com>
Date: Mon, 3 Sep 2012 10:44:21 +0800
Message-ID: <CACQ=j+f_UKXrBWSjFXUe=waRSPxJX=8yn_xPpDi_jUwziGT7Ug@mail.gmail.com>
To: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Cc: www-style@w3.org
On Sun, Sep 2, 2012 at 7:31 PM, Glenn Adams <glenn@skynav.com> wrote:

>
> On Sun, Sep 2, 2012 at 3:46 PM, Daniel Glazman <
> daniel.glazman@disruptive-innovations.com> wrote:
>
>>
>> 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
>>
>
> If the deletion of a Node that refers to a stylesheet causes the
> stylesheet to be deleted, then it should delete every rule if there are no
> live references to one of its rules; otherwise, if there is a live
> reference to one of its rule or to the stylesheet, then the stylesheet and
> node should not be deleted until that live reference is non-reachable.
>

On further investigation, I note the CSSStyleSheet.prototype.deleteRule
allows deleting a rule from a stylesheet. This may be the one place where
it makes sense to spec that parentStyleSheet should be nulled out.

For example, one could have:

<style id='style1'></style>
<script>
var sheet = document.getElementByID('style1').sheet;
sheet.insertRule('body { color: red; }',0);
var rule = sheet.cssRules[0];
assert(rule.parentStyleSheet === sheet);
sheet.deleteRule(0);
assert(rule.parentStyleSheet === null);
</script>

How does that sound? If this is agreeable, then I'll make parentStyleSheet
nullable and spec deleteRule as nulling parentStyleSheet.

[Note that we still need spec text that says if the style/link element is
merely removed from the DOM that doesn't mean its stylesheet or rules go
away.]
Received on Monday, 3 September 2012 02:45:09 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:59 GMT