File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,37 @@ To use the new binary you need to set the **`DENO_DOM_PLUGIN`** env var to the
139
139
path of the binary produced in the previous step. ** Don't forget** to run Deno
140
140
with ` --allow-env ` .
141
141
142
+ ## Inconsistencies with standard APIs
143
+
144
+ ### Differences in ` DOMTokenList ` /` Element.classList `
145
+
146
+ To optimize memory usage, Deno DOM doesn't allocate ` DOMTokenList ` s
147
+ (` Element.classList ` ) on ` Element ` creation, it instead creates an
148
+ ` UninitializedDOMTokenList ` object. This can cause a subtle deviation
149
+ from standard APIs:
150
+
151
+ ``` typescript
152
+ const div = doc .createElement (" div" );
153
+
154
+ // Retrieve the uninitialized DOMTokenList
155
+ const { classList } = div ;
156
+
157
+ // Initialize the DOMTokenList by adding a few classes
158
+ classList .add (" foo" );
159
+ classList .add (" bar" );
160
+
161
+ // Inconsistency: the uninitialized classList/DOMTokenList
162
+ // is now a different object from the initialized one
163
+
164
+ classList !== div .classList ;
165
+
166
+ // However, the uninitialized DOMTokenList object still
167
+ // works as the initialized DOMTokenList object:
168
+
169
+ classList .add (" fizz" );
170
+ div .classList .contains (" fizz" ) === true ;
171
+ ```
172
+
142
173
# Credits
143
174
144
175
- html5ever developers for the HTML parser
You can’t perform that action at this time.
0 commit comments