domino 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/.travis.yml +1 -0
  2. package/CHANGELOG.md +66 -1
  3. package/README.md +20 -9
  4. package/lib/CSSStyleDeclaration.js +291 -19
  5. package/lib/CharacterData.js +15 -18
  6. package/lib/ChildNode.js +6 -1
  7. package/lib/Comment.js +7 -1
  8. package/lib/ContainerNode.js +7 -2
  9. package/lib/DOMException.js +2 -2
  10. package/lib/DOMImplementation.js +18 -10
  11. package/lib/DOMTokenList.js +125 -43
  12. package/lib/Document.js +150 -57
  13. package/lib/DocumentType.js +3 -6
  14. package/lib/Element.js +426 -127
  15. package/lib/FilteredElementList.js +13 -12
  16. package/lib/HTMLParser.js +15 -2
  17. package/lib/NamedNodeMap.js +41 -0
  18. package/lib/Node.js +43 -12
  19. package/lib/NodeIterator.js +110 -39
  20. package/lib/NodeList.es5.js +15 -0
  21. package/lib/NodeList.es6.js +12 -0
  22. package/lib/NodeList.js +9 -9
  23. package/lib/ProcessingInstruction.js +7 -1
  24. package/lib/Text.js +16 -5
  25. package/lib/TreeWalker.js +143 -98
  26. package/lib/URL.js +3 -1
  27. package/lib/URLUtils.js +204 -184
  28. package/lib/Window.js +1 -1
  29. package/lib/htmlelts.js +66 -14
  30. package/lib/impl.js +1 -0
  31. package/lib/index.d.ts +5 -0
  32. package/lib/index.js +2 -2
  33. package/lib/select.js +19 -10
  34. package/lib/utils.js +6 -1
  35. package/package.json +6 -4
  36. package/test/domino.js +327 -4
  37. package/test/w3c/level1/core/hc_characterdataindexsizeerrdeletedatacountnegative.js +1 -0
  38. package/test/w3c/level1/core/hc_characterdataindexsizeerrreplacedatacountnegative.js +1 -0
  39. package/test/w3c/level1/core/hc_characterdataindexsizeerrsubstringcountnegative.js +1 -0
  40. package/test/web-platform-blacklist.json +4669 -0
  41. package/test/web-platform-tests.js +289 -223
  42. package/test/xss.js +85 -0
package/.travis.yml CHANGED
@@ -3,6 +3,7 @@ node_js:
3
3
  - "4"
4
4
  - "6"
5
5
  - "8"
6
+ - "10"
6
7
  # From the nvm docs, "this installs the latest version of node".
7
8
  - "node"
8
9
 
package/CHANGELOG.md CHANGED
@@ -1,4 +1,69 @@
1
- # domino x.x.x (not yet released)
1
+ # domino 2.1.0 (13 Aug 2018)
2
+ * Fix `ContainerNode#removeChildren()` when there is more than one child (#129)
3
+ * Implement `Document#scrollingElement` (#107)
4
+ * Implement setter for `Element#outerHTML` (#102)
5
+ * Handle null/undefined in setter for `Node#textContent`
6
+ * Handle null/undefined/negative values in `CharacterData` interface methods
7
+ * Spec-correctness fixes for `DOMTokenList`, including handling of duplicate
8
+ keys.
9
+ * Fix `[src=...]` selectors in `Document#querySelector()` and similar
10
+ * Spec-correctness fixes for `Document#createElement()` and
11
+ `Document#createElementNS()`, including proper exception type and type
12
+ coercion.
13
+ * Implement `Attr#cloneNode()`, `Element#getAttributeNode()`,
14
+ `Element#getAttributeNodeNS()`, `Element#setAttributeNode()`,
15
+ `Element#setAttributeNodeNS()`, and `Element#removeAttributeNode()`
16
+ (DOM3 compatibility)
17
+ * Implement `Document#createAttribute()` and `Document#createAttributeNS()`
18
+ * Implement `Element#hasAttributes()`, `Element#toggleAttribute()`, and
19
+ `Element#getAttributeNames()`
20
+ * Implement `Text#wholeText`
21
+ * Implement `Document#cloneNode()` and `DocumentType#cloneNode()`
22
+ * Spec-correctness fixes for `Node#lookupPrefix()`,
23
+ `Node#lookupNamespaceURI()`, and `Node#isDefaultNamespace`, including
24
+ proper type coercion and reconciling DOM 3 and DOM 4 specifications.
25
+ * Ensure `Document#title` continues to use correct whitespace stripping
26
+ for node > 4, and properly set `<title>` when `undefined` is passed to
27
+ `DOMImplementation#createHTMLDocument()`
28
+ * Ensure `Element#attributes` implements `NamedNodeMap` and that indexed
29
+ properties of `Element#attributes` work (previously you needed to use
30
+ the `item()` accessor method)
31
+ * Improve stubs for `HTMLElement#style`, `Document#documentURI`, and
32
+ `Document#contentType`
33
+ * Implement proper accessors for `HTMLSelectElement#autocomplete`,
34
+ `HTMLTextAreaElement#type/value/defaultValue/textLength`, and
35
+ `HTMLInputElement#width/height/minLength`
36
+ * Implement `Element#insertAdjacentElement()`, `Element#insertAdjacentText()`,
37
+ and `Element#insertAdjacentHTML()` (#102)
38
+ * Spec-correctness fixes for `TreeWalker` and `NodeIterator`: read-only
39
+ properties, proper exception types, type coercion of `NodeFilter` results.
40
+ * Implement `NodeIterator` pre-removal steps. Note that in the absence
41
+ of weak references, be cautious about the number of `NodeIterator`s you
42
+ create on any single document, since domino does not artificially limit
43
+ these.
44
+ See https://github.com/tc39/proposal-weakrefs/issues/17 for details.
45
+ * Preserve prefix of SVG elements during parsing. (#102)
46
+
47
+ # domino 2.0.3 (12 Jul 2018)
48
+ * Define `blur()`, `focus()` and `forceSpellCheck()` on `HTMLElement` (#125)
49
+ * Stringify argument tokens for DOMTokenList methods (#126)
50
+ * Fix `HTMLAnchorElement#hash` when `href` attribute contains bare
51
+ fragment (#127)
52
+ * Implement case-insensitive CSS attribute matching (#128)
53
+ * Implement `DOMTokenList#replace()`, `DOMTokenList#toggle(token, force)`,
54
+ and `DOMTokenList#value`. Fix handling of non-space whitespace. (#111)
55
+
56
+ # domino 2.0.2 (28 Mar 2018)
57
+ * Add TypeScript definitions (#103)
58
+ * Add `flex` CSS styles (#119, #120)
59
+ * Fix Element#matches with ~= selectors (#121)
60
+
61
+ # domino 2.0.1 (14 Feb 2018)
62
+ * Allow attributes named 'xmlns' (#112)
63
+ * Make DOMTokenList add/remove variadic (#109)
64
+ * Make `Array.from` and for-of loops work on `Node#attributes`.
65
+
66
+ # domino 2.0.0 ( 8 Nov 2017)
2
67
  * Fix potential O(N^2) slowdown in FilteredElementList#item.
3
68
  * `mocha` dependency has been updated to 4.0.x. As a result, we are
4
69
  no longer testing on node pre-v4.0.0; see:
package/README.md CHANGED
@@ -6,21 +6,24 @@ As the name might suggest, domino's goal is to provide a <b>DOM in No</b>de.
6
6
 
7
7
  In contrast to the original [dom.js](https://github.com/andreasgal/dom.js) project, domino was not designed to run untrusted code. Hence it doesn't have to hide its internals behind a proxy facade which makes the code not only simpler, but also [more performant](https://github.com/fgnass/dombench).
8
8
 
9
- Domino currently doesn't use any harmony features like proxies or WeakMaps and therefore also runs in older Node versions.
9
+ Domino currently doesn't use any harmony/ES6 features like proxies or WeakMaps and therefore also runs in older Node versions.
10
10
 
11
11
  ## Speed over Compliance
12
12
 
13
13
  Domino is intended for _building_ pages rather than scraping them. Hence Domino doesn't execute scripts nor does it download external resources.
14
14
 
15
- Also Domino doesn't implement any properties which have been deprecated in HTML5.
15
+ Also Domino doesn't generally implement properties which have been deprecated in HTML5.
16
16
 
17
- Domino sticks to the [DOM level 4](http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-attr) working draft, which means that Attributes do not inherit the Node interface. Also [Element.attributes](http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-attributes) returns a read-only array instead of a NamedNodeMap.
17
+ Domino sticks to [DOM level 4](http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-attr), which means that Attributes do not inherit the Node interface.
18
18
 
19
19
  <b>Note that</b> because domino does not use proxies,
20
20
  `Element.attributes` is not a true JavaScript array; it is an object
21
21
  with a `length` property and an `item(n)` accessor method. See
22
22
  [github issue #27](https://github.com/fgnass/domino/issues/27) for
23
- further discussion.
23
+ further discussion. It does however implement direct indexed accessors
24
+ (`element.attributes[i]`) and is live.
25
+
26
+
24
27
 
25
28
  ## CSS Selector Support
26
29
 
@@ -81,17 +84,25 @@ var domino = require('domino');
81
84
  Domino includes test from the [W3C DOM Conformance Suites](http://www.w3.org/DOM/Test/)
82
85
  as well as tests from [HTML Working Group](http://www.w3.org/html/wg/wiki/Testing).
83
86
 
84
- The tests can be run via `npm test` or directly though the [Mocha](http://visionmedia.github.com/mocha/) command line:
87
+ The tests can be run via `npm test` or directly though the [Mocha](http://mochajs.org/) command line:
85
88
 
86
89
  ![Screenshot](http://fgnass.github.com/images/domino.png)
87
90
 
88
91
  ## License and Credits
89
92
 
90
- The majority of the code was written by [Andreas Gal](https://github.com/andreasgal/) and [David Flanagan](https://github.com/davidflanagan) as part of the [dom.js](https://github.com/andreasgal/dom.js) project. Please refer to the included LICENSE file for the original copyright notice and disclaimer.
93
+ The majority of the code was originally written by [Andreas Gal](https://github.com/andreasgal/) and [David Flanagan](https://github.com/davidflanagan) as part of the [dom.js](https://github.com/andreasgal/dom.js) project. Please refer to the included LICENSE file for the original copyright notice and disclaimer.
94
+
95
+ [Felix Gnass](https://github.com/fgnass/) extracted the code and turned
96
+ it into a stand-alone npm package.
97
+
98
+ The code has been maintained since 2013 by [C. Scott Ananian](https://github.com/cscott/) on behalf of the Wikimedia Foundation, which uses it in its
99
+ [Parsoid](https://www.mediawiki.org/wiki/Parsoid) project. A large number
100
+ of improvements have been made, mostly focusing on correctness,
101
+ performance, and (to a lesser extent) completeness of the implementation.
91
102
 
92
- [1]: https://travis-ci.org/fgnass/domino.png
103
+ [1]: https://travis-ci.org/fgnass/domino.svg
93
104
  [2]: https://travis-ci.org/fgnass/domino
94
- [3]: https://david-dm.org/fgnass/domino.png
105
+ [3]: https://david-dm.org/fgnass/domino.svg
95
106
  [4]: https://david-dm.org/fgnass/domino
96
- [5]: https://david-dm.org/fgnass/domino/dev-status.png
107
+ [5]: https://david-dm.org/fgnass/domino/dev-status.svg
97
108
  [6]: https://david-dm.org/fgnass/domino#info=devDependencies
@@ -187,109 +187,370 @@ CSSStyleDeclaration.prototype = Object.create(Object.prototype, {
187
187
  });
188
188
 
189
189
  var cssProperties = {
190
+ alignContent: "align-content",
191
+ alignItems: "align-items",
192
+ alignmentBaseline: "alignment-baseline",
193
+ alignSelf: "align-self",
194
+ animation: "animation",
195
+ animationDelay: "animation-delay",
196
+ animationDirection: "animation-direction",
197
+ animationDuration: "animation-duration",
198
+ animationFillMode: "animation-fill-mode",
199
+ animationIterationCount: "animation-iteration-count",
200
+ animationName: "animation-name",
201
+ animationPlayState: "animation-play-state",
202
+ animationTimingFunction: "animation-timing-function",
203
+ backfaceVisibility: "backface-visibility",
190
204
  background: "background",
191
205
  backgroundAttachment: "background-attachment",
206
+ backgroundClip: "background-clip",
192
207
  backgroundColor: "background-color",
193
208
  backgroundImage: "background-image",
209
+ backgroundOrigin: "background-origin",
194
210
  backgroundPosition: "background-position",
211
+ backgroundPositionX: "background-position-x",
212
+ backgroundPositionY: "background-position-y",
195
213
  backgroundRepeat: "background-repeat",
214
+ backgroundSize: "background-size",
215
+ baselineShift: "baseline-shift",
196
216
  border: "border",
217
+ borderBottom: "border-bottom",
218
+ borderBottomColor: "border-bottom-color",
219
+ borderBottomLeftRadius: "border-bottom-left-radius",
220
+ borderBottomRightRadius: "border-bottom-right-radius",
221
+ borderBottomStyle: "border-bottom-style",
222
+ borderBottomWidth: "border-bottom-width",
197
223
  borderCollapse: "border-collapse",
198
224
  borderColor: "border-color",
225
+ borderImage: "border-image",
226
+ borderImageOutset: "border-image-outset",
227
+ borderImageRepeat: "border-image-repeat",
228
+ borderImageSlice: "border-image-slice",
229
+ borderImageSource: "border-image-source",
230
+ borderImageWidth: "border-image-width",
231
+ borderLeft: "border-left",
232
+ borderLeftColor: "border-left-color",
233
+ borderLeftStyle: "border-left-style",
234
+ borderLeftWidth: "border-left-width",
235
+ borderRadius: "border-radius",
236
+ borderRight: "border-right",
237
+ borderRightColor: "border-right-color",
238
+ borderRightStyle: "border-right-style",
239
+ borderRightWidth: "border-right-width",
199
240
  borderSpacing: "border-spacing",
200
241
  borderStyle: "border-style",
201
242
  borderTop: "border-top",
202
- borderRight: "border-right",
203
- borderBottom: "border-bottom",
204
- borderLeft: "border-left",
205
243
  borderTopColor: "border-top-color",
206
- borderRightColor: "border-right-color",
207
- borderBottomColor: "border-bottom-color",
208
- borderLeftColor: "border-left-color",
244
+ borderTopLeftRadius: "border-top-left-radius",
245
+ borderTopRightRadius: "border-top-right-radius",
209
246
  borderTopStyle: "border-top-style",
210
- borderRightStyle: "border-right-style",
211
- borderBottomStyle: "border-bottom-style",
212
- borderLeftStyle: "border-left-style",
213
247
  borderTopWidth: "border-top-width",
214
- borderRightWidth: "border-right-width",
215
- borderBottomWidth: "border-bottom-width",
216
- borderLeftWidth: "border-left-width",
217
248
  borderWidth: "border-width",
218
249
  bottom: "bottom",
250
+ boxShadow: "box-shadow",
251
+ boxSizing: "box-sizing",
252
+ breakAfter: "break-after",
253
+ breakBefore: "break-before",
254
+ breakInside: "break-inside",
219
255
  captionSide: "caption-side",
220
256
  clear: "clear",
221
257
  clip: "clip",
258
+ clipPath: "clip-path",
259
+ clipRule: "clip-rule",
222
260
  color: "color",
261
+ colorInterpolationFilters: "color-interpolation-filters",
262
+ columnCount: "column-count",
263
+ columnFill: "column-fill",
264
+ columnGap: "column-gap",
265
+ columnRule: "column-rule",
266
+ columnRuleColor: "column-rule-color",
267
+ columnRuleStyle: "column-rule-style",
268
+ columnRuleWidth: "column-rule-width",
269
+ columns: "columns",
270
+ columnSpan: "column-span",
271
+ columnWidth: "column-width",
223
272
  content: "content",
224
273
  counterIncrement: "counter-increment",
225
274
  counterReset: "counter-reset",
275
+ cssFloat: "float",
226
276
  cursor: "cursor",
227
277
  direction: "direction",
228
278
  display: "display",
279
+ dominantBaseline: "dominant-baseline",
229
280
  emptyCells: "empty-cells",
230
- cssFloat: "float",
281
+ enableBackground: "enable-background",
282
+ fill: "fill",
283
+ fillOpacity: "fill-opacity",
284
+ fillRule: "fill-rule",
285
+ filter: "filter",
286
+ flex: "flex",
287
+ flexBasis: "flex-basis",
288
+ flexDirection: "flex-direction",
289
+ flexFlow: "flex-flow",
290
+ flexGrow: "flex-grow",
291
+ flexShrink: "flex-shrink",
292
+ flexWrap: "flex-wrap",
293
+ floodColor: "flood-color",
294
+ floodOpacity: "flood-opacity",
231
295
  font: "font",
232
296
  fontFamily: "font-family",
297
+ fontFeatureSettings: "font-feature-settings",
233
298
  fontSize: "font-size",
234
299
  fontSizeAdjust: "font-size-adjust",
235
300
  fontStretch: "font-stretch",
236
301
  fontStyle: "font-style",
237
302
  fontVariant: "font-variant",
238
303
  fontWeight: "font-weight",
304
+ glyphOrientationHorizontal: "glyph-orientation-horizontal",
305
+ glyphOrientationVertical: "glyph-orientation-vertical",
306
+ grid: "grid",
307
+ gridArea: "grid-area",
308
+ gridAutoColumns: "grid-auto-columns",
309
+ gridAutoFlow: "grid-auto-flow",
310
+ gridAutoRows: "grid-auto-rows",
311
+ gridColumn: "grid-column",
312
+ gridColumnEnd: "grid-column-end",
313
+ gridColumnGap: "grid-column-gap",
314
+ gridColumnStart: "grid-column-start",
315
+ gridGap: "grid-gap",
316
+ gridRow: "grid-row",
317
+ gridRowEnd: "grid-row-end",
318
+ gridRowGap: "grid-row-gap",
319
+ gridRowStart: "grid-row-start",
320
+ gridTemplate: "grid-template",
321
+ gridTemplateAreas: "grid-template-areas",
322
+ gridTemplateColumns: "grid-template-columns",
323
+ gridTemplateRows: "grid-template-rows",
239
324
  height: "height",
325
+ imeMode: "ime-mode",
326
+ justifyContent: "justify-content",
327
+ kerning: "kerning",
328
+ layoutGrid: "layout-grid",
329
+ layoutGridChar: "layout-grid-char",
330
+ layoutGridLine: "layout-grid-line",
331
+ layoutGridMode: "layout-grid-mode",
332
+ layoutGridType: "layout-grid-type",
240
333
  left: "left",
241
334
  letterSpacing: "letter-spacing",
335
+ lightingColor: "lighting-color",
336
+ lineBreak: "line-break",
242
337
  lineHeight: "line-height",
243
338
  listStyle: "list-style",
244
339
  listStyleImage: "list-style-image",
245
340
  listStylePosition: "list-style-position",
246
341
  listStyleType: "list-style-type",
247
342
  margin: "margin",
248
- marginTop: "margin-top",
249
- marginRight: "margin-right",
250
343
  marginBottom: "margin-bottom",
251
344
  marginLeft: "margin-left",
252
- markerOffset: "marker-offset",
253
- marks: "marks",
345
+ marginRight: "margin-right",
346
+ marginTop: "margin-top",
347
+ marker: "marker",
348
+ markerEnd: "marker-end",
349
+ markerMid: "marker-mid",
350
+ markerStart: "marker-start",
351
+ mask: "mask",
254
352
  maxHeight: "max-height",
255
353
  maxWidth: "max-width",
256
354
  minHeight: "min-height",
257
355
  minWidth: "min-width",
356
+ msContentZoomChaining: "-ms-content-zoom-chaining",
357
+ msContentZooming: "-ms-content-zooming",
358
+ msContentZoomLimit: "-ms-content-zoom-limit",
359
+ msContentZoomLimitMax: "-ms-content-zoom-limit-max",
360
+ msContentZoomLimitMin: "-ms-content-zoom-limit-min",
361
+ msContentZoomSnap: "-ms-content-zoom-snap",
362
+ msContentZoomSnapPoints: "-ms-content-zoom-snap-points",
363
+ msContentZoomSnapType: "-ms-content-zoom-snap-type",
364
+ msFlowFrom: "-ms-flow-from",
365
+ msFlowInto: "-ms-flow-into",
366
+ msFontFeatureSettings: "-ms-font-feature-settings",
367
+ msGridColumn: "-ms-grid-column",
368
+ msGridColumnAlign: "-ms-grid-column-align",
369
+ msGridColumns: "-ms-grid-columns",
370
+ msGridColumnSpan: "-ms-grid-column-span",
371
+ msGridRow: "-ms-grid-row",
372
+ msGridRowAlign: "-ms-grid-row-align",
373
+ msGridRows: "-ms-grid-rows",
374
+ msGridRowSpan: "-ms-grid-row-span",
375
+ msHighContrastAdjust: "-ms-high-contrast-adjust",
376
+ msHyphenateLimitChars: "-ms-hyphenate-limit-chars",
377
+ msHyphenateLimitLines: "-ms-hyphenate-limit-lines",
378
+ msHyphenateLimitZone: "-ms-hyphenate-limit-zone",
379
+ msHyphens: "-ms-hyphens",
380
+ msImeAlign: "-ms-ime-align",
381
+ msOverflowStyle: "-ms-overflow-style",
382
+ msScrollChaining: "-ms-scroll-chaining",
383
+ msScrollLimit: "-ms-scroll-limit",
384
+ msScrollLimitXMax: "-ms-scroll-limit-x-max",
385
+ msScrollLimitXMin: "-ms-scroll-limit-x-min",
386
+ msScrollLimitYMax: "-ms-scroll-limit-y-max",
387
+ msScrollLimitYMin: "-ms-scroll-limit-y-min",
388
+ msScrollRails: "-ms-scroll-rails",
389
+ msScrollSnapPointsX: "-ms-scroll-snap-points-x",
390
+ msScrollSnapPointsY: "-ms-scroll-snap-points-y",
391
+ msScrollSnapType: "-ms-scroll-snap-type",
392
+ msScrollSnapX: "-ms-scroll-snap-x",
393
+ msScrollSnapY: "-ms-scroll-snap-y",
394
+ msScrollTranslation: "-ms-scroll-translation",
395
+ msTextCombineHorizontal: "-ms-text-combine-horizontal",
396
+ msTextSizeAdjust: "-ms-text-size-adjust",
397
+ msTouchAction: "-ms-touch-action",
398
+ msTouchSelect: "-ms-touch-select",
399
+ msUserSelect: "-ms-user-select",
400
+ msWrapFlow: "-ms-wrap-flow",
401
+ msWrapMargin: "-ms-wrap-margin",
402
+ msWrapThrough: "-ms-wrap-through",
258
403
  opacity: "opacity",
404
+ order: "order",
259
405
  orphans: "orphans",
260
406
  outline: "outline",
261
407
  outlineColor: "outline-color",
408
+ outlineOffset: "outline-offset",
262
409
  outlineStyle: "outline-style",
263
410
  outlineWidth: "outline-width",
264
411
  overflow: "overflow",
412
+ overflowX: "overflow-x",
413
+ overflowY: "overflow-y",
265
414
  padding: "padding",
266
- paddingTop: "padding-top",
267
- paddingRight: "padding-right",
268
415
  paddingBottom: "padding-bottom",
269
416
  paddingLeft: "padding-left",
417
+ paddingRight: "padding-right",
418
+ paddingTop: "padding-top",
270
419
  page: "page",
271
420
  pageBreakAfter: "page-break-after",
272
421
  pageBreakBefore: "page-break-before",
273
422
  pageBreakInside: "page-break-inside",
423
+ perspective: "perspective",
424
+ perspectiveOrigin: "perspective-origin",
425
+ pointerEvents: "pointer-events",
274
426
  position: "position",
275
427
  quotes: "quotes",
276
428
  right: "right",
429
+ rotate: "rotate",
430
+ rubyAlign: "ruby-align",
431
+ rubyOverhang: "ruby-overhang",
432
+ rubyPosition: "ruby-position",
433
+ scale: "scale",
277
434
  size: "size",
435
+ stopColor: "stop-color",
436
+ stopOpacity: "stop-opacity",
437
+ stroke: "stroke",
438
+ strokeDasharray: "stroke-dasharray",
439
+ strokeDashoffset: "stroke-dashoffset",
440
+ strokeLinecap: "stroke-linecap",
441
+ strokeLinejoin: "stroke-linejoin",
442
+ strokeMiterlimit: "stroke-miterlimit",
443
+ strokeOpacity: "stroke-opacity",
444
+ strokeWidth: "stroke-width",
278
445
  tableLayout: "table-layout",
279
446
  textAlign: "text-align",
447
+ textAlignLast: "text-align-last",
448
+ textAnchor: "text-anchor",
280
449
  textDecoration: "text-decoration",
281
450
  textIndent: "text-indent",
451
+ textJustify: "text-justify",
452
+ textKashida: "text-kashida",
453
+ textKashidaSpace: "text-kashida-space",
454
+ textOverflow: "text-overflow",
282
455
  textShadow: "text-shadow",
283
456
  textTransform: "text-transform",
457
+ textUnderlinePosition: "text-underline-position",
284
458
  top: "top",
459
+ touchAction: "touch-action",
460
+ transform: "transform",
461
+ transformOrigin: "transform-origin",
462
+ transformStyle: "transform-style",
463
+ transition: "transition",
464
+ transitionDelay: "transition-delay",
465
+ transitionDuration: "transition-duration",
466
+ transitionProperty: "transition-property",
467
+ transitionTimingFunction: "transition-timing-function",
468
+ translate: "translate",
285
469
  unicodeBidi: "unicode-bidi",
286
470
  verticalAlign: "vertical-align",
287
471
  visibility: "visibility",
472
+ webkitAlignContent: "-webkit-align-content",
473
+ webkitAlignItems: "-webkit-align-items",
474
+ webkitAlignSelf: "-webkit-align-self",
475
+ webkitAnimation: "-webkit-animation",
476
+ webkitAnimationDelay: "-webkit-animation-delay",
477
+ webkitAnimationDirection: "-webkit-animation-direction",
478
+ webkitAnimationDuration: "-webkit-animation-duration",
479
+ webkitAnimationFillMode: "-webkit-animation-fill-mode",
480
+ webkitAnimationIterationCount: "-webkit-animation-iteration-count",
481
+ webkitAnimationName: "-webkit-animation-name",
482
+ webkitAnimationPlayState: "-webkit-animation-play-state",
483
+ webkitAnimationTimingFunction: "-webkit-animation-timing-funciton",
484
+ webkitAppearance: "-webkit-appearance",
485
+ webkitBackfaceVisibility: "-webkit-backface-visibility",
486
+ webkitBackgroundClip: "-webkit-background-clip",
487
+ webkitBackgroundOrigin: "-webkit-background-origin",
488
+ webkitBackgroundSize: "-webkit-background-size",
489
+ webkitBorderBottomLeftRadius: "-webkit-border-bottom-left-radius",
490
+ webkitBorderBottomRightRadius: "-webkit-border-bottom-right-radius",
491
+ webkitBorderImage: "-webkit-border-image",
492
+ webkitBorderRadius: "-webkit-border-radius",
493
+ webkitBorderTopLeftRadius: "-webkit-border-top-left-radius",
494
+ webkitBorderTopRightRadius: "-webkit-border-top-right-radius",
495
+ webkitBoxAlign: "-webkit-box-align",
496
+ webkitBoxDirection: "-webkit-box-direction",
497
+ webkitBoxFlex: "-webkit-box-flex",
498
+ webkitBoxOrdinalGroup: "-webkit-box-ordinal-group",
499
+ webkitBoxOrient: "-webkit-box-orient",
500
+ webkitBoxPack: "-webkit-box-pack",
501
+ webkitBoxSizing: "-webkit-box-sizing",
502
+ webkitColumnBreakAfter: "-webkit-column-break-after",
503
+ webkitColumnBreakBefore: "-webkit-column-break-before",
504
+ webkitColumnBreakInside: "-webkit-column-break-inside",
505
+ webkitColumnCount: "-webkit-column-count",
506
+ webkitColumnGap: "-webkit-column-gap",
507
+ webkitColumnRule: "-webkit-column-rule",
508
+ webkitColumnRuleColor: "-webkit-column-rule-color",
509
+ webkitColumnRuleStyle: "-webkit-column-rule-style",
510
+ webkitColumnRuleWidth: "-webkit-column-rule-width",
511
+ webkitColumns: "-webkit-columns",
512
+ webkitColumnSpan: "-webkit-column-span",
513
+ webkitColumnWidth: "-webkit-column-width",
514
+ webkitFilter: "-webkit-filter",
515
+ webkitFlex: "-webkit-flex",
516
+ webkitFlexBasis: "-webkit-flex-basis",
517
+ webkitFlexDirection: "-webkit-flex-direction",
518
+ webkitFlexFlow: "-webkit-flex-flow",
519
+ webkitFlexGrow: "-webkit-flex-grow",
520
+ webkitFlexShrink: "-webkit-flex-shrink",
521
+ webkitFlexWrap: "-webkit-flex-wrap",
522
+ webkitJustifyContent: "-webkit-justify-content",
523
+ webkitOrder: "-webkit-order",
524
+ webkitPerspective: "-webkit-perspective-origin",
525
+ webkitPerspectiveOrigin: "-webkit-perspective-origin",
526
+ webkitTapHighlightColor: "-webkit-tap-highlight-color",
527
+ webkitTextFillColor: "-webkit-text-fill-color",
528
+ webkitTextSizeAdjust: "-webkit-text-size-adjust",
529
+ webkitTextStroke: "-webkit-text-stroke",
530
+ webkitTextStrokeColor: "-webkit-text-stroke-color",
531
+ webkitTextStrokeWidth: "-webkit-text-stroke-width",
532
+ webkitTransform: "-webkit-transform",
533
+ webkitTransformOrigin: "-webkit-transform-origin",
534
+ webkitTransformStyle: "-webkit-transform-style",
535
+ webkitTransition: "-webkit-transition",
536
+ webkitTransitionDelay: "-webkit-transition-delay",
537
+ webkitTransitionDuration: "-webkit-transition-duration",
538
+ webkitTransitionProperty: "-webkit-transition-property",
539
+ webkitTransitionTimingFunction: "-webkit-transition-timing-function",
540
+ webkitUserModify: "-webkit-user-modify",
541
+ webkitUserSelect: "-webkit-user-select",
542
+ webkitWritingMode: "-webkit-writing-mode",
288
543
  whiteSpace: "white-space",
289
544
  widows: "widows",
290
545
  width: "width",
546
+ wordBreak: "word-break",
291
547
  wordSpacing: "word-spacing",
548
+ wordWrap: "word-wrap",
549
+ writingMode: "writing-mode",
292
550
  zIndex: "z-index",
551
+ zoom: "zoom",
552
+ resize: "resize",
553
+ userSelect: "user-select",
293
554
  };
294
555
 
295
556
  for(var prop in cssProperties) defineStyleProperty(prop);
@@ -304,4 +565,15 @@ function defineStyleProperty(jsname) {
304
565
  this.setProperty(cssname, value);
305
566
  }
306
567
  });
568
+
569
+ if (!CSSStyleDeclaration.prototype.hasOwnProperty(cssname)) {
570
+ Object.defineProperty(CSSStyleDeclaration.prototype, cssname, {
571
+ get: function() {
572
+ return this.getPropertyValue(cssname);
573
+ },
574
+ set: function(value) {
575
+ this.setProperty(cssname, value);
576
+ }
577
+ });
578
+ }
307
579
  }
@@ -1,3 +1,4 @@
1
+ /* jshint bitwise: false */
1
2
  "use strict";
2
3
  module.exports = CharacterData;
3
4
 
@@ -28,8 +29,13 @@ CharacterData.prototype = Object.create(Leaf.prototype, {
28
29
  // units from the offsetth UTF-16 code unit to the
29
30
  // offset+countth UTF-16 code unit in data.
30
31
  substringData: { value: function substringData(offset, count) {
31
- if (offset > this.data.length || offset < 0 || count < 0)
32
+ if (arguments.length < 2) { throw new TypeError("Not enough arguments"); }
33
+ // Convert arguments to WebIDL "unsigned long"
34
+ offset = offset >>> 0;
35
+ count = count >>> 0;
36
+ if (offset > this.data.length || offset < 0 || count < 0) {
32
37
  utils.IndexSizeError();
38
+ }
33
39
  return this.data.substring(offset, offset+count);
34
40
  }},
35
41
 
@@ -37,7 +43,8 @@ CharacterData.prototype = Object.create(Leaf.prototype, {
37
43
  // The appendData(data) method must append data to the context
38
44
  // object's data.
39
45
  appendData: { value: function appendData(data) {
40
- this.data = this.data + data;
46
+ if (arguments.length < 1) { throw new TypeError("Not enough arguments"); }
47
+ this.data += String(data);
41
48
  }},
42
49
 
43
50
  // void insertData(unsigned long offset, DOMString data);
@@ -51,11 +58,7 @@ CharacterData.prototype = Object.create(Leaf.prototype, {
51
58
  // offset UTF-16 code units.
52
59
  //
53
60
  insertData: { value: function insertData(offset, data) {
54
- var curtext = this.data;
55
- if (offset > curtext.length || offset < 0) utils.IndexSizeError();
56
- var prefix = curtext.substring(0, offset),
57
- suffix = curtext.substring(offset);
58
- this.data = prefix + data + suffix;
61
+ return this.replaceData(offset, 0, data);
59
62
  }},
60
63
 
61
64
 
@@ -72,17 +75,7 @@ CharacterData.prototype = Object.create(Leaf.prototype, {
72
75
  // Starting from offset UTF-16 code units remove count
73
76
  // UTF-16 code units from the context object's data.
74
77
  deleteData: { value: function deleteData(offset, count) {
75
- var curtext = this.data, len = curtext.length;
76
-
77
- if (offset > len || offset < 0) utils.IndexSizeError();
78
-
79
- if (offset+count > len)
80
- count = len - offset;
81
-
82
- var prefix = curtext.substring(0, offset),
83
- suffix = curtext.substring(offset+count);
84
-
85
- this.data = prefix + suffix;
78
+ return this.replaceData(offset, count, '');
86
79
  }},
87
80
 
88
81
 
@@ -96,6 +89,10 @@ CharacterData.prototype = Object.create(Leaf.prototype, {
96
89
  // exceptions these methods might have thrown.
97
90
  replaceData: { value: function replaceData(offset, count, data) {
98
91
  var curtext = this.data, len = curtext.length;
92
+ // Convert arguments to correct WebIDL type
93
+ offset = offset >>> 0;
94
+ count = count >>> 0;
95
+ data = String(data);
99
96
 
100
97
  if (offset > len || offset < 0) utils.IndexSizeError();
101
98
 
package/lib/ChildNode.js CHANGED
@@ -62,7 +62,12 @@ var ChildNode = {
62
62
  if (this.parentNode === null) return;
63
63
 
64
64
  // Send mutation events if necessary
65
- if (this.rooted && this.doc) this.doc.mutateRemove(this);
65
+ if (this.doc) {
66
+ this.doc._preremoveNodeIterators(this);
67
+ if (this.rooted) {
68
+ this.doc.mutateRemove(this);
69
+ }
70
+ }
66
71
 
67
72
  // Remove this node from its parents array of children
68
73
  // and update the structure id for all ancestors
package/lib/Comment.js CHANGED
@@ -14,6 +14,7 @@ function Comment(doc, data) {
14
14
  var nodeValue = {
15
15
  get: function() { return this._data; },
16
16
  set: function(v) {
17
+ if (v === null || v === undefined) { v = ''; } else { v = String(v); }
17
18
  this._data = v;
18
19
  if (this.rooted)
19
20
  this.ownerDocument.mutateValue(this);
@@ -24,7 +25,12 @@ Comment.prototype = Object.create(CharacterData.prototype, {
24
25
  nodeName: { value: '#comment' },
25
26
  nodeValue: nodeValue,
26
27
  textContent: nodeValue,
27
- data: nodeValue,
28
+ data: {
29
+ get: nodeValue.get,
30
+ set: function(v) {
31
+ nodeValue.set.call(this, v===null ? '' : String(v));
32
+ },
33
+ },
28
34
 
29
35
  // Utility methods
30
36
  clone: { value: function clone() {
@@ -59,8 +59,13 @@ ContainerNode.prototype = Object.create(Node.prototype, {
59
59
  // Remove all of this node's children. This is a minor
60
60
  // optimization that only calls modify() once.
61
61
  removeChildren: { value: function removeChildren() {
62
- var root = this.rooted ? this.ownerDocument : null;
63
- for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
62
+ var root = this.rooted ? this.ownerDocument : null,
63
+ next = this.firstChild,
64
+ kid;
65
+ while (next !== null) {
66
+ kid = next;
67
+ next = kid.nextSibling;
68
+
64
69
  if (root) root.mutateRemove(kid);
65
70
  kid.parentNode = null;
66
71
  }