@@ -9,23 +9,24 @@ var allExtraProperties = require('./allExtraProperties');
9
9
var implementedProperties = require ( './implementedProperties' ) ;
10
10
var { dashedToCamelCase } = require ( './parsers' ) ;
11
11
var getBasicPropertyDescriptor = require ( './utils/getBasicPropertyDescriptor' ) ;
12
+ const idlUtils = require ( './utils.js' ) ;
12
13
13
- /**
14
- * @constructor
15
- * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
16
- */
17
- var CSSStyleDeclaration = function CSSStyleDeclaration ( onChangeCallback ) {
18
- this . _values = { } ;
19
- this . _importants = { } ;
20
- this . _length = 0 ;
21
- this . _onChange =
22
- onChangeCallback ||
23
- function ( ) {
24
- return ;
25
- } ;
26
- } ;
27
- CSSStyleDeclaration . prototype = {
28
- constructor : CSSStyleDeclaration ,
14
+ class CSSStyleDeclaration {
15
+ /**
16
+ * @constructor
17
+ * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
18
+ */
19
+ constructor ( globalObject , args , { onChangeCallback } ) {
20
+ this . _globalObject = globalObject ;
21
+ this . _values = { } ;
22
+ this . _importants = { } ;
23
+ this . _length = 0 ;
24
+ this . _onChange =
25
+ onChangeCallback ||
26
+ function ( ) {
27
+ return ;
28
+ } ;
29
+ }
29
30
30
31
/**
31
32
*
@@ -34,12 +35,12 @@ CSSStyleDeclaration.prototype = {
34
35
* @return {string } the value of the property if it has been explicitly set for this declaration block.
35
36
* Returns the empty string if the property has not been set.
36
37
*/
37
- getPropertyValue : function ( name ) {
38
+ getPropertyValue ( name ) {
38
39
if ( ! this . _values . hasOwnProperty ( name ) ) {
39
40
return '' ;
40
41
}
41
42
return this . _values [ name ] . toString ( ) ;
42
- } ,
43
+ }
43
44
44
45
/**
45
46
*
@@ -48,7 +49,7 @@ CSSStyleDeclaration.prototype = {
48
49
* @param {string } [priority=null] "important" or null
49
50
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-setProperty
50
51
*/
51
- setProperty : function ( name , value , priority ) {
52
+ setProperty ( name , value , priority ) {
52
53
if ( value === undefined ) {
53
54
return ;
54
55
}
@@ -68,8 +69,9 @@ CSSStyleDeclaration.prototype = {
68
69
69
70
this [ lowercaseName ] = value ;
70
71
this . _importants [ lowercaseName ] = priority ;
71
- } ,
72
- _setProperty : function ( name , value , priority ) {
72
+ }
73
+
74
+ _setProperty ( name , value , priority ) {
73
75
if ( value === undefined ) {
74
76
return ;
75
77
}
@@ -92,7 +94,7 @@ CSSStyleDeclaration.prototype = {
92
94
this . _values [ name ] = value ;
93
95
this . _importants [ name ] = priority ;
94
96
this . _onChange ( this . cssText ) ;
95
- } ,
97
+ }
96
98
97
99
/**
98
100
*
@@ -101,7 +103,7 @@ CSSStyleDeclaration.prototype = {
101
103
* @return {string } the value of the property if it has been explicitly set for this declaration block.
102
104
* Returns the empty string if the property has not been set or the property name does not correspond to a known CSS property.
103
105
*/
104
- removeProperty : function ( name ) {
106
+ removeProperty ( name ) {
105
107
if ( ! this . _values . hasOwnProperty ( name ) ) {
106
108
return '' ;
107
109
}
@@ -123,47 +125,30 @@ CSSStyleDeclaration.prototype = {
123
125
124
126
this . _onChange ( this . cssText ) ;
125
127
return prevValue ;
126
- } ,
128
+ }
127
129
128
130
/**
129
131
*
130
132
* @param {String } name
131
133
*/
132
- getPropertyPriority : function ( name ) {
134
+ getPropertyPriority ( name ) {
133
135
return this . _importants [ name ] || '' ;
134
- } ,
135
-
136
- getPropertyCSSValue : function ( ) {
137
- //FIXME
138
- return ;
139
- } ,
140
-
141
- /**
142
- * element.style.overflow = "auto"
143
- * element.style.getPropertyShorthand("overflow-x")
144
- * -> "overflow"
145
- */
146
- getPropertyShorthand : function ( ) {
147
- //FIXME
148
- return ;
149
- } ,
150
-
151
- isPropertyImplicit : function ( ) {
152
- //FIXME
153
- return ;
154
- } ,
136
+ }
155
137
156
138
/**
157
139
* http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-item
158
140
*/
159
- item : function ( index ) {
160
- index = parseInt ( index , 10 ) ;
141
+ item ( index ) {
161
142
if ( index < 0 || index >= this . _length ) {
162
143
return '' ;
163
144
}
164
145
return this [ index ] ;
165
- } ,
166
- } ;
146
+ }
147
+
148
+ [ idlUtils . supportsPropertyIndex ] ( index ) {
149
+ return index >= 0 && index < this . _length ;
150
+ }
151
+ }
167
152
168
153
Object . defineProperties ( CSSStyleDeclaration . prototype , {
169
154
cssText : {
@@ -257,4 +242,4 @@ allExtraProperties.forEach(function(property) {
257
242
}
258
243
} ) ;
259
244
260
- exports . CSSStyleDeclaration = CSSStyleDeclaration ;
245
+ exports . implementation = CSSStyleDeclaration ;
0 commit comments