Skip to content

Commit d25b006

Browse files
committed
[cssom] Per WG resolution, tombstone the CSSRule.type attribute. Fixes w3c#4142.
1 parent bacb9b7 commit d25b006

File tree

1 file changed

+48
-29
lines changed

1 file changed

+48
-29
lines changed

cssom-1/Overview.bs

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,45 +1706,23 @@ inherits from this interface.
17061706
<pre class=idl>
17071707
[Exposed=Window]
17081708
interface CSSRule {
1709+
attribute CSSOMString cssText;
1710+
readonly attribute CSSRule? parentRule;
1711+
readonly attribute CSSStyleSheet? parentStyleSheet;
1712+
1713+
// the following attribute and constants are historial
1714+
readonly attribute unsigned short type;
17091715
const unsigned short STYLE_RULE = 1;
1710-
const unsigned short CHARSET_RULE = 2; // historical
1716+
const unsigned short CHARSET_RULE = 2;
17111717
const unsigned short IMPORT_RULE = 3;
17121718
const unsigned short MEDIA_RULE = 4;
17131719
const unsigned short FONT_FACE_RULE = 5;
17141720
const unsigned short PAGE_RULE = 6;
17151721
const unsigned short MARGIN_RULE = 9;
17161722
const unsigned short NAMESPACE_RULE = 10;
1717-
readonly attribute unsigned short type;
1718-
attribute CSSOMString cssText;
1719-
readonly attribute CSSRule? parentRule;
1720-
readonly attribute CSSStyleSheet? parentStyleSheet;
17211723
};
17221724
</pre>
17231725

1724-
The <dfn attribute for=CSSRule>type</dfn> attribute must return the CSS rule type, as follows:
1725-
1726-
<dl class=switch>
1727-
<dt>If the object is a {{CSSStyleRule}}
1728-
<dd>Return <dfn const for=CSSRule>STYLE_RULE</dfn> (numeric value 1).
1729-
<dt>If the object is a {{CSSImportRule}}
1730-
<dd>Return <dfn const for=CSSRule>IMPORT_RULE</dfn> (numeric value 3).
1731-
<dt>If the object is a {{CSSMediaRule}}
1732-
<dd>Return <dfn const for=CSSRule>MEDIA_RULE</dfn> (numeric value 4).
1733-
<dt>If the object is a {{CSSFontFaceRule}}
1734-
<dd>Return <dfn const for=CSSRule>FONT_FACE_RULE</dfn> (numeric value 5).
1735-
<dt>If the object is a {{CSSPageRule}}
1736-
<dd>Return <dfn const for=CSSRule>PAGE_RULE</dfn> (numeric value 6).
1737-
<dt>If the object is a {{CSSMarginRule}}
1738-
<dd>Return <dfn const for=CSSRule>MARGIN_RULE</dfn> (numeric value 9).
1739-
<dt>If the object is a {{CSSNamespaceRule}}
1740-
<dd>Return <dfn const for=CSSRule>NAMESPACE_RULE</dfn> (numeric value 10).
1741-
<dt>Otherwise
1742-
<dd>Return a value defined on the <a href="https://wiki.csswg.org/spec/cssom-constants">CSSOM Constants</a> wiki page.
1743-
</dl>
1744-
1745-
Note: The value 0, formerly known as <code>UNKNOWN_RULE</code>, is made
1746-
obsolete by this specification. This value will not be re-allocated in the future and will remain reserved.
1747-
17481726
The <dfn attribute for=CSSRule>cssText</dfn> attribute must return a <a lt="serialize a CSS rule">serialization</a> of the
17491727
<a for=/>CSS rule</a>.
17501728
On setting the {{CSSRule/cssText}} attribute must do nothing.
@@ -1764,6 +1742,47 @@ Note: Removing a <code>Node</code> that implements the <code>LinkStyle</code> in
17641742
{{Document}} instance does not (by itself) cause the <code>CSSStyleSheet</code> referenced by a <code>CSSRule</code> to be
17651743
unreachable.
17661744

1745+
The <dfn attribute for=CSSRule>type</dfn> attribute is deprecated.
1746+
It must return an integer, as follows:
1747+
1748+
<dl class=switch dfn-type=const dfn-for=CSSRule>
1749+
<dt>If the object is a {{CSSStyleRule}}
1750+
<dd>Return 1.
1751+
<dt>If the object is a {{CSSImportRule}}
1752+
<dd>Return 3.
1753+
<dt>If the object is a {{CSSMediaRule}}
1754+
<dd>Return 4.
1755+
<dt>If the object is a {{CSSFontFaceRule}}
1756+
<dd>Return 5.
1757+
<dt>If the object is a {{CSSPageRule}}
1758+
<dd>Return 6.
1759+
<dt>If the object is a {{CSSKeyframesRule}}
1760+
<dd>Return 7.
1761+
<dt>If the object is a {{CSSKeyframeRule}}
1762+
<dd>Return 8.
1763+
<dt>If the object is a {{CSSMarginRule}}
1764+
<dd>Return 9.
1765+
<dt>If the object is a {{CSSNamespaceRule}}
1766+
<dd>Return 10.
1767+
<dt>If the object is a {{CSSCounterStyleRule}}
1768+
<dd>Return 11.
1769+
<dt>If the object is a {{CSSSupportsRule}}
1770+
<dd>Return 12.
1771+
<dt>If the object is a {{CSSFontFeatureValuesRule}}
1772+
<dd>Return 14.
1773+
<dt>If the object is a {{CSSViewportRule}}
1774+
<dd>Return 15.
1775+
<dt>Otherwise
1776+
<dd>Return 0.
1777+
</dl>
1778+
1779+
Note: The practice of using an integer enumeration
1780+
and several constants to <em>identify</em> the integers
1781+
is a legacy design practice that is no longer used in Web APIs.
1782+
Instead, to tell what type of rule a given object is,
1783+
it is recommended to check <code highlight=js>rule.constructor.name</code>,
1784+
which will return a string like <code highlight=js>"CSSStyleRule"</code>.
1785+
17671786

17681787
### The {{CSSStyleRule}} Interface ### {#the-cssstylerule-interface}
17691788

0 commit comments

Comments
 (0)