Skip to content

Commit 21c8712

Browse files
committed
Add support for CSSRule.type
1 parent 45fa7ea commit 21c8712

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

lib/cssom/CSSRule-impl.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11

2+
import {
3+
CSSCounterStyleRule,
4+
CSSFontFaceRule,
5+
CSSFontFeatureValuesRule,
6+
CSSImportRule,
7+
CSSKeyframeRule,
8+
CSSKeyframesRule,
9+
CSSMarginRule,
10+
CSSMediaRule,
11+
CSSNamespaceRule,
12+
CSSPageRule,
13+
CSSStyleRule,
14+
CSSSupportsRule,
15+
}
16+
from '../cssom/index.js'
17+
218
/**
319
* @see {@link https://drafts.csswg.org/cssom-1/#cssrule}
420
*/
@@ -14,4 +30,48 @@ export default class CSSRuleImpl {
1430
this.parentRule = parentRule
1531
this.parentStyleSheet = parentStyleSheet
1632
}
33+
34+
/**
35+
* @return {number}
36+
* @see {@link https://drafts.csswg.org/cssom-1/#dom-cssrule-type}
37+
*/
38+
get type() {
39+
if (CSSStyleRule.isImpl(this)) {
40+
return 1
41+
}
42+
if (CSSImportRule.isImpl(this)) {
43+
return 3
44+
}
45+
if (CSSMediaRule.isImpl(this)) {
46+
return 4
47+
}
48+
if (CSSFontFaceRule.isImpl(this)) {
49+
return 5
50+
}
51+
if (CSSPageRule.isImpl(this)) {
52+
return 6
53+
}
54+
if (CSSKeyframesRule.isImpl(this)) {
55+
return 7
56+
}
57+
if (CSSKeyframeRule.isImpl(this)) {
58+
return 8
59+
}
60+
if (CSSMarginRule.isImpl(this)) {
61+
return 9
62+
}
63+
if (CSSNamespaceRule.isImpl(this)) {
64+
return 10
65+
}
66+
if (CSSCounterStyleRule.isImpl(this)) {
67+
return 11
68+
}
69+
if (CSSSupportsRule.isImpl(this)) {
70+
return 12
71+
}
72+
if (CSSFontFeatureValuesRule.isImpl(this)) {
73+
return 14
74+
}
75+
return 0
76+
}
1777
}

0 commit comments

Comments
 (0)