pseudo-dom 0.6.0 → 0.7.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 (122) hide show
  1. package/README.md +432 -13
  2. package/browser/pseudo-dom.js +3364 -603
  3. package/browser/pseudo-dom.min.js +1 -1
  4. package/dist/classes/PseudoEventListener.d.ts +96 -96
  5. package/dist/classes/PseudoEventListener.js +151 -151
  6. package/dist/classes/PseudoHTMLDocument.d.ts +67 -67
  7. package/dist/classes/PseudoHTMLDocument.js +144 -144
  8. package/dist/classes/PseudoNodeList.d.ts +34 -34
  9. package/dist/classes/PseudoNodeList.js +71 -71
  10. package/dist/classes.d.ts +20 -20
  11. package/dist/classes.js +31 -31
  12. package/dist/factories/createEvent.d.ts +28 -28
  13. package/dist/factories/createEvent.js +56 -56
  14. package/dist/factories/cssSelectAdapter.d.ts +23 -0
  15. package/dist/factories/cssSelectAdapter.js +87 -0
  16. package/dist/factories/cssSelectAdapter.min.js +1 -0
  17. package/dist/factories/eventDefaults.d.ts +31 -31
  18. package/dist/factories/eventDefaults.js +105 -105
  19. package/dist/factories/generateDocument.d.ts +11 -11
  20. package/dist/factories/generateDocument.js +65 -65
  21. package/dist/factories/generateNode.d.ts +32 -32
  22. package/dist/factories/generateNode.js +85 -85
  23. package/dist/factories/generateNodeList.d.ts +9 -9
  24. package/dist/factories/generateNodeList.js +13 -13
  25. package/dist/factories/query.d.ts +33 -0
  26. package/dist/factories/query.js +66 -0
  27. package/dist/factories/query.min.js +1 -0
  28. package/dist/factories.d.ts +11 -11
  29. package/dist/factories.js +27 -27
  30. package/dist/functions/activeElement.d.ts +14 -14
  31. package/dist/functions/activeElement.js +33 -33
  32. package/dist/functions/getParentNodes.d.ts +11 -11
  33. package/dist/functions/getParentNodes.js +22 -22
  34. package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
  35. package/dist/functions/getParentNodesFromAttribute.js +29 -29
  36. package/dist/functions/modifierState.d.ts +29 -29
  37. package/dist/functions/modifierState.js +41 -41
  38. package/dist/functions.d.ts +5 -5
  39. package/dist/functions.js +23 -23
  40. package/dist/interfaces/PseudoAnimation.d.ts +3 -3
  41. package/dist/interfaces/PseudoAnimation.js +5 -5
  42. package/dist/interfaces/PseudoAttr.d.ts +11 -11
  43. package/dist/interfaces/PseudoAttr.js +5 -5
  44. package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
  45. package/dist/interfaces/PseudoDOMTokenList.js +5 -5
  46. package/dist/interfaces/PseudoDocument.d.ts +7 -0
  47. package/dist/interfaces/PseudoDocument.js +5 -5
  48. package/dist/interfaces/PseudoDocumentFragment.d.ts +3 -3
  49. package/dist/interfaces/PseudoDocumentFragment.js +5 -5
  50. package/dist/interfaces/PseudoElement.d.ts +20 -7
  51. package/dist/interfaces/PseudoElement.js +5 -5
  52. package/dist/interfaces/PseudoEvent.d.ts +79 -79
  53. package/dist/interfaces/PseudoEvent.js +10 -10
  54. package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
  55. package/dist/interfaces/PseudoEventTarget.js +5 -5
  56. package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
  57. package/dist/interfaces/PseudoHTMLCollection.js +5 -5
  58. package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
  59. package/dist/interfaces/PseudoHTMLElement.js +5 -5
  60. package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
  61. package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
  62. package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
  63. package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
  64. package/dist/interfaces/PseudoNode.d.ts +179 -179
  65. package/dist/interfaces/PseudoNode.js +5 -5
  66. package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
  67. package/dist/interfaces/PseudoShadowRoot.js +5 -5
  68. package/dist/main.d.ts +63 -63
  69. package/dist/main.js +155 -155
  70. package/dist/services/AnimationService.d.ts +4 -4
  71. package/dist/services/AnimationService.js +16 -16
  72. package/dist/services/AttrService.d.ts +37 -37
  73. package/dist/services/AttrService.js +81 -81
  74. package/dist/services/CommentService.d.ts +1 -1
  75. package/dist/services/CommentService.js +13 -13
  76. package/dist/services/CustomEventService.d.ts +37 -37
  77. package/dist/services/CustomEventService.js +35 -35
  78. package/dist/services/DOMTokenListService.d.ts +33 -33
  79. package/dist/services/DOMTokenListService.js +117 -117
  80. package/dist/services/DocumentFragmentService.d.ts +13 -13
  81. package/dist/services/DocumentFragmentService.js +24 -24
  82. package/dist/services/DocumentService.d.ts +7 -0
  83. package/dist/services/DocumentService.js +23 -0
  84. package/dist/services/DocumentService.min.js +1 -1
  85. package/dist/services/ElementService.d.ts +13 -0
  86. package/dist/services/ElementService.js +20 -0
  87. package/dist/services/ElementService.min.js +1 -1
  88. package/dist/services/EventService.d.ts +120 -120
  89. package/dist/services/EventService.js +250 -250
  90. package/dist/services/EventTargetService.d.ts +84 -84
  91. package/dist/services/EventTargetService.js +232 -232
  92. package/dist/services/FocusEventService.d.ts +32 -32
  93. package/dist/services/FocusEventService.js +35 -35
  94. package/dist/services/HTMLCollectionService.d.ts +11 -6
  95. package/dist/services/HTMLCollectionService.js +25 -8
  96. package/dist/services/HTMLCollectionService.min.js +1 -1
  97. package/dist/services/HTMLElementService.d.ts +57 -57
  98. package/dist/services/HTMLElementService.js +163 -163
  99. package/dist/services/HTMLSlotElementService.d.ts +4 -4
  100. package/dist/services/HTMLSlotElementService.js +9 -9
  101. package/dist/services/InputEventService.d.ts +41 -41
  102. package/dist/services/InputEventService.js +47 -47
  103. package/dist/services/KeyboardEventService.d.ts +70 -70
  104. package/dist/services/KeyboardEventService.js +86 -86
  105. package/dist/services/MouseEventService.d.ts +80 -80
  106. package/dist/services/MouseEventService.js +108 -108
  107. package/dist/services/NamedNodeMapService.d.ts +23 -23
  108. package/dist/services/NamedNodeMapService.js +77 -77
  109. package/dist/services/NodeService.d.ts +26 -0
  110. package/dist/services/NodeService.js +42 -0
  111. package/dist/services/NodeService.min.js +1 -1
  112. package/dist/services/PointerEventService.d.ts +51 -51
  113. package/dist/services/PointerEventService.js +67 -67
  114. package/dist/services/ShadowRootService.d.ts +4 -4
  115. package/dist/services/ShadowRootService.js +9 -9
  116. package/dist/services/TextService.d.ts +1 -1
  117. package/dist/services/TextService.js +13 -13
  118. package/dist/services/UIEventService.d.ts +43 -43
  119. package/dist/services/UIEventService.js +42 -42
  120. package/dist/simulate.d.ts +32 -32
  121. package/dist/simulate.js +115 -115
  122. package/package.json +3 -2
package/README.md CHANGED
@@ -45,9 +45,15 @@ children, \`childElementCount\`, \`firstElementChild\` / \`lastElementChild\` an
45
45
  a tree rather than duplicating it; \`insertAdjacentElement\` / \`insertAdjacentText\` insert at beforebegin / afterbegin
46
46
  / beforeend / afterend (\`insertAdjacentHTML\` is not implemented, no HTML parsing yet).
47
47
 
48
- Not implemented yet (these throw a "not implemented" error or are missing): `querySelector` /
49
- `querySelectorAll`, `innerHTML` / `outerHTML` parsing, and most of the rest of the Element and Document APIs. The API
50
- will change before 1.0.
48
+ Selector queries work like the DOM's: \`getElementsByTagName\` / \`getElementsByClassName\` (live, on any node) and
49
+ \`querySelector\` / \`querySelectorAll\` (real CSS selectors, via [css-select](https://www.npmjs.com/package/css-select)
50
+ matched against pseudo-dom's own tree through a custom adapter - \`querySelectorAll\` is a plain array, a snapshot
51
+ taken when it is called, like the DOM's) are on \`NodeService\` so \`Document\`, \`DocumentFragment\` and \`Element\`
52
+ all have them; \`matches\` / \`closest\` are on \`ElementService\`; \`getElementById\` is on \`DocumentService\` only,
53
+ matching the real DOM.
54
+
55
+ Not implemented yet (these throw a "not implemented" error or are missing): \`getElementsByTagNameNS\`, \`innerHTML\` /
56
+ \`outerHTML\` parsing, and most of the rest of the Element and Document APIs. The API will change before 1.0.
51
57
  ## Modules
52
58
 
53
59
  <dl>
@@ -94,8 +100,8 @@ interface (the mouse, the keyboard, focus and input).</p>
94
100
  <dd><p>Simulate the behaviour of the HTMLElement Class when there is no DOM available.</p>
95
101
  </dd>
96
102
  <dt><a href="#HTMLCollectionService">HTMLCollectionService</a></dt>
97
- <dd><p>Simulate the behaviour of the HTMLCollection Class when there is no DOM available: a live view of the element
98
- children of a node, recomputed from its childNodes each time it is used rather than kept in sync as they change.</p>
103
+ <dd><p>Simulate the behaviour of the HTMLCollection Class when there is no DOM available: a live view of some of a node&#39;s
104
+ element descendants, recomputed each time it is used rather than kept in sync as they change.</p>
99
105
  </dd>
100
106
  <dt><a href="#FocusEventService">FocusEventService</a> ⇐ <code><a href="#UIEventService">UIEventService</a></code></dt>
101
107
  <dd><p>Simulate the behaviour of the FocusEvent Class when there is no DOM available.</p>
@@ -200,6 +206,9 @@ tree (or list) of nodes from plain values.</p>
200
206
  <dd><p>Construct the Pseudo Dom to provide access to Dom objects which are otherwise not available outside the browser
201
207
  context.</p>
202
208
  </dd>
209
+ <dt><a href="#nearestElementSibling">nearestElementSibling(node, direction)</a> ⇒ <code>*</code> | <code>null</code></dt>
210
+ <dd><p>Walk up from a node (not including it) to find the nearest element, in the given direction.</p>
211
+ </dd>
203
212
  <dt><a href="#createEvent">createEvent(type, [init], [options])</a> ⇒ <code><a href="#EventService">EventService</a></code></dt>
204
213
  <dd><p>Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
205
214
  By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
@@ -456,6 +465,10 @@ Simulate the behaviour of the Node Class when there is no DOM available.
456
465
  * [.replaceWith(...nodes)](#NodeService+replaceWith)
457
466
  * [.remove()](#NodeService+remove)
458
467
  * [.toChildNode(value)](#NodeService+toChildNode) ⇒ <code>PseudoNode</code>
468
+ * [.getElementsByTagName(tagName)](#NodeService+getElementsByTagName) ⇒ <code>PseudoHTMLCollection</code>
469
+ * [.getElementsByClassName(className)](#NodeService+getElementsByClassName) ⇒ <code>PseudoHTMLCollection</code>
470
+ * [.querySelector(selectors)](#NodeService+querySelector) ⇒ <code>PseudoElement</code> \| <code>null</code>
471
+ * [.querySelectorAll(selectors)](#NodeService+querySelectorAll) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
459
472
  * [.childInserted(child)](#NodeService+childInserted)
460
473
  * [.cloneNode([deep])](#NodeService+cloneNode) ⇒ <code>PseudoNode</code>
461
474
  * [.compareDocumentPosition(otherNode)](#NodeService+compareDocumentPosition) ⇒ <code>number</code>
@@ -602,6 +615,51 @@ becomes a text node belonging to this node's document, anything else is returned
602
615
  | --- | --- | --- |
603
616
  | value | <code>PseudoNode</code> \| <code>string</code> | The value to add |
604
617
 
618
+ <a name="NodeService+getElementsByTagName"></a>
619
+
620
+ ### nodeService.getElementsByTagName(tagName) ⇒ <code>PseudoHTMLCollection</code>
621
+ Every element below this node with the given tag name (or every element when tagName is *), live.
622
+
623
+ **Kind**: instance method of [<code>NodeService</code>](#NodeService)
624
+
625
+ | Param | Type |
626
+ | --- | --- |
627
+ | tagName | <code>string</code> |
628
+
629
+ <a name="NodeService+getElementsByClassName"></a>
630
+
631
+ ### nodeService.getElementsByClassName(className) ⇒ <code>PseudoHTMLCollection</code>
632
+ Every element below this node which has all of the given (space separated) classes, live.
633
+
634
+ **Kind**: instance method of [<code>NodeService</code>](#NodeService)
635
+
636
+ | Param | Type |
637
+ | --- | --- |
638
+ | className | <code>string</code> |
639
+
640
+ <a name="NodeService+querySelector"></a>
641
+
642
+ ### nodeService.querySelector(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
643
+ The first element below this node which matches the CSS selector, in tree order, or null when there is none.
644
+
645
+ **Kind**: instance method of [<code>NodeService</code>](#NodeService)
646
+
647
+ | Param | Type | Description |
648
+ | --- | --- | --- |
649
+ | selectors | <code>string</code> | A CSS selector |
650
+
651
+ <a name="NodeService+querySelectorAll"></a>
652
+
653
+ ### nodeService.querySelectorAll(selectors) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
654
+ Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
655
+ collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
656
+
657
+ **Kind**: instance method of [<code>NodeService</code>](#NodeService)
658
+
659
+ | Param | Type | Description |
660
+ | --- | --- | --- |
661
+ | selectors | <code>string</code> | A CSS selector |
662
+
605
663
  <a name="NodeService+childInserted"></a>
606
664
 
607
665
  ### nodeService.childInserted(child)
@@ -752,6 +810,10 @@ Simulate the behaviour of the Text Class when there is no DOM available: the tex
752
810
  * [.replaceWith(...nodes)](#NodeService+replaceWith)
753
811
  * [.remove()](#NodeService+remove)
754
812
  * [.toChildNode(value)](#NodeService+toChildNode) ⇒ <code>PseudoNode</code>
813
+ * [.getElementsByTagName(tagName)](#NodeService+getElementsByTagName) ⇒ <code>PseudoHTMLCollection</code>
814
+ * [.getElementsByClassName(className)](#NodeService+getElementsByClassName) ⇒ <code>PseudoHTMLCollection</code>
815
+ * [.querySelector(selectors)](#NodeService+querySelector) ⇒ <code>PseudoElement</code> \| <code>null</code>
816
+ * [.querySelectorAll(selectors)](#NodeService+querySelectorAll) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
755
817
  * [.childInserted(child)](#NodeService+childInserted)
756
818
  * [.cloneNode([deep])](#NodeService+cloneNode) ⇒ <code>PseudoNode</code>
757
819
  * [.compareDocumentPosition(otherNode)](#NodeService+compareDocumentPosition) ⇒ <code>number</code>
@@ -935,6 +997,55 @@ becomes a text node belonging to this node's document, anything else is returned
935
997
  | --- | --- | --- |
936
998
  | value | <code>PseudoNode</code> \| <code>string</code> | The value to add |
937
999
 
1000
+ <a name="NodeService+getElementsByTagName"></a>
1001
+
1002
+ ### textService.getElementsByTagName(tagName) ⇒ <code>PseudoHTMLCollection</code>
1003
+ Every element below this node with the given tag name (or every element when tagName is *), live.
1004
+
1005
+ **Kind**: instance method of [<code>TextService</code>](#TextService)
1006
+ **Overrides**: [<code>getElementsByTagName</code>](#NodeService+getElementsByTagName)
1007
+
1008
+ | Param | Type |
1009
+ | --- | --- |
1010
+ | tagName | <code>string</code> |
1011
+
1012
+ <a name="NodeService+getElementsByClassName"></a>
1013
+
1014
+ ### textService.getElementsByClassName(className) ⇒ <code>PseudoHTMLCollection</code>
1015
+ Every element below this node which has all of the given (space separated) classes, live.
1016
+
1017
+ **Kind**: instance method of [<code>TextService</code>](#TextService)
1018
+ **Overrides**: [<code>getElementsByClassName</code>](#NodeService+getElementsByClassName)
1019
+
1020
+ | Param | Type |
1021
+ | --- | --- |
1022
+ | className | <code>string</code> |
1023
+
1024
+ <a name="NodeService+querySelector"></a>
1025
+
1026
+ ### textService.querySelector(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
1027
+ The first element below this node which matches the CSS selector, in tree order, or null when there is none.
1028
+
1029
+ **Kind**: instance method of [<code>TextService</code>](#TextService)
1030
+ **Overrides**: [<code>querySelector</code>](#NodeService+querySelector)
1031
+
1032
+ | Param | Type | Description |
1033
+ | --- | --- | --- |
1034
+ | selectors | <code>string</code> | A CSS selector |
1035
+
1036
+ <a name="NodeService+querySelectorAll"></a>
1037
+
1038
+ ### textService.querySelectorAll(selectors) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
1039
+ Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
1040
+ collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
1041
+
1042
+ **Kind**: instance method of [<code>TextService</code>](#TextService)
1043
+ **Overrides**: [<code>querySelectorAll</code>](#NodeService+querySelectorAll)
1044
+
1045
+ | Param | Type | Description |
1046
+ | --- | --- | --- |
1047
+ | selectors | <code>string</code> | A CSS selector |
1048
+
938
1049
  <a name="NodeService+childInserted"></a>
939
1050
 
940
1051
  ### textService.childInserted(child)
@@ -1092,6 +1203,10 @@ Simulate the behaviour of the Comment Class when there is no DOM available: a no
1092
1203
  * [.replaceWith(...nodes)](#NodeService+replaceWith)
1093
1204
  * [.remove()](#NodeService+remove)
1094
1205
  * [.toChildNode(value)](#NodeService+toChildNode) ⇒ <code>PseudoNode</code>
1206
+ * [.getElementsByTagName(tagName)](#NodeService+getElementsByTagName) ⇒ <code>PseudoHTMLCollection</code>
1207
+ * [.getElementsByClassName(className)](#NodeService+getElementsByClassName) ⇒ <code>PseudoHTMLCollection</code>
1208
+ * [.querySelector(selectors)](#NodeService+querySelector) ⇒ <code>PseudoElement</code> \| <code>null</code>
1209
+ * [.querySelectorAll(selectors)](#NodeService+querySelectorAll) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
1095
1210
  * [.childInserted(child)](#NodeService+childInserted)
1096
1211
  * [.cloneNode([deep])](#NodeService+cloneNode) ⇒ <code>PseudoNode</code>
1097
1212
  * [.compareDocumentPosition(otherNode)](#NodeService+compareDocumentPosition) ⇒ <code>number</code>
@@ -1258,6 +1373,55 @@ becomes a text node belonging to this node's document, anything else is returned
1258
1373
  | --- | --- | --- |
1259
1374
  | value | <code>PseudoNode</code> \| <code>string</code> | The value to add |
1260
1375
 
1376
+ <a name="NodeService+getElementsByTagName"></a>
1377
+
1378
+ ### commentService.getElementsByTagName(tagName) ⇒ <code>PseudoHTMLCollection</code>
1379
+ Every element below this node with the given tag name (or every element when tagName is *), live.
1380
+
1381
+ **Kind**: instance method of [<code>CommentService</code>](#CommentService)
1382
+ **Overrides**: [<code>getElementsByTagName</code>](#NodeService+getElementsByTagName)
1383
+
1384
+ | Param | Type |
1385
+ | --- | --- |
1386
+ | tagName | <code>string</code> |
1387
+
1388
+ <a name="NodeService+getElementsByClassName"></a>
1389
+
1390
+ ### commentService.getElementsByClassName(className) ⇒ <code>PseudoHTMLCollection</code>
1391
+ Every element below this node which has all of the given (space separated) classes, live.
1392
+
1393
+ **Kind**: instance method of [<code>CommentService</code>](#CommentService)
1394
+ **Overrides**: [<code>getElementsByClassName</code>](#NodeService+getElementsByClassName)
1395
+
1396
+ | Param | Type |
1397
+ | --- | --- |
1398
+ | className | <code>string</code> |
1399
+
1400
+ <a name="NodeService+querySelector"></a>
1401
+
1402
+ ### commentService.querySelector(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
1403
+ The first element below this node which matches the CSS selector, in tree order, or null when there is none.
1404
+
1405
+ **Kind**: instance method of [<code>CommentService</code>](#CommentService)
1406
+ **Overrides**: [<code>querySelector</code>](#NodeService+querySelector)
1407
+
1408
+ | Param | Type | Description |
1409
+ | --- | --- | --- |
1410
+ | selectors | <code>string</code> | A CSS selector |
1411
+
1412
+ <a name="NodeService+querySelectorAll"></a>
1413
+
1414
+ ### commentService.querySelectorAll(selectors) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
1415
+ Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
1416
+ collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
1417
+
1418
+ **Kind**: instance method of [<code>CommentService</code>](#CommentService)
1419
+ **Overrides**: [<code>querySelectorAll</code>](#NodeService+querySelectorAll)
1420
+
1421
+ | Param | Type | Description |
1422
+ | --- | --- | --- |
1423
+ | selectors | <code>string</code> | A CSS selector |
1424
+
1261
1425
  <a name="NodeService+childInserted"></a>
1262
1426
 
1263
1427
  ### commentService.childInserted(child)
@@ -1715,14 +1879,14 @@ Take the focus away from the element, when it has it: it gets blur then focusout
1715
1879
  <a name="HTMLCollectionService"></a>
1716
1880
 
1717
1881
  ## HTMLCollectionService
1718
- Simulate the behaviour of the HTMLCollection Class when there is no DOM available: a live view of the element
1719
- children of a node, recomputed from its childNodes each time it is used rather than kept in sync as they change.
1882
+ Simulate the behaviour of the HTMLCollection Class when there is no DOM available: a live view of some of a node's
1883
+ element descendants, recomputed each time it is used rather than kept in sync as they change.
1720
1884
 
1721
1885
  **Kind**: global class
1722
1886
  **Author**: Joshua Heagle <joshuaheagle@gmail.com>
1723
1887
 
1724
1888
  * [HTMLCollectionService](#HTMLCollectionService)
1725
- * [new HTMLCollectionService(owner)](#new_HTMLCollectionService_new)
1889
+ * [new HTMLCollectionService(owner, [predicate], [deep])](#new_HTMLCollectionService_new)
1726
1890
  * [.length](#HTMLCollectionService+length) ⇒ <code>number</code>
1727
1891
  * [.elements()](#HTMLCollectionService+elements) ⇒ <code>Array.&lt;PseudoNode&gt;</code>
1728
1892
  * [.item(index)](#HTMLCollectionService+item) ⇒ <code>\*</code>
@@ -1730,11 +1894,13 @@ children of a node, recomputed from its childNodes each time it is used rather t
1730
1894
 
1731
1895
  <a name="new_HTMLCollectionService_new"></a>
1732
1896
 
1733
- ### new HTMLCollectionService(owner)
1897
+ ### new HTMLCollectionService(owner, [predicate], [deep])
1734
1898
 
1735
- | Param | Type | Description |
1736
- | --- | --- | --- |
1737
- | owner | [<code>NodeService</code>](#NodeService) | The node whose element children this is a live view of |
1899
+ | Param | Type | Default | Description |
1900
+ | --- | --- | --- | --- |
1901
+ | owner | [<code>NodeService</code>](#NodeService) | | The node this is a live view of a part of |
1902
+ | [predicate] | <code>function</code> | | Only elements which pass this are included (every element by default) |
1903
+ | [deep] | <code>boolean</code> | <code>false</code> | Include every matching descendant (true, like getElementsByTagName), not just the direct element children (false, like Element.children) |
1738
1904
 
1739
1905
  <a name="HTMLCollectionService+length"></a>
1740
1906
 
@@ -1745,7 +1911,7 @@ How many elements are in the collection right now.
1745
1911
  <a name="HTMLCollectionService+elements"></a>
1746
1912
 
1747
1913
  ### htmlCollectionService.elements() ⇒ <code>Array.&lt;PseudoNode&gt;</code>
1748
- The current element children of the owner, in order.
1914
+ The current elements the collection holds, in tree order.
1749
1915
 
1750
1916
  **Kind**: instance method of [<code>HTMLCollectionService</code>](#HTMLCollectionService)
1751
1917
  <a name="HTMLCollectionService+item"></a>
@@ -2085,6 +2251,8 @@ Simulate the behaviour of the Element Class when there is no DOM available.
2085
2251
  * [.insertAdjacentText(position, text)](#ElementService+insertAdjacentText)
2086
2252
  * [.insertAdjacent(position, node)](#ElementService+insertAdjacent) ⇒ <code>PseudoNode</code> \| <code>null</code>
2087
2253
  * [.insertAdjacentHTML(position, text)](#ElementService+insertAdjacentHTML)
2254
+ * [.matches(selectors)](#ElementService+matches) ⇒ <code>boolean</code>
2255
+ * [.closest(selectors)](#ElementService+closest) ⇒ <code>PseudoElement</code> \| <code>null</code>
2088
2256
  * [.childInserted(child)](#ElementService+childInserted)
2089
2257
  * [.hasAttribute(attributeName)](#ElementService+hasAttribute) ⇒ <code>boolean</code>
2090
2258
  * [.setAttribute(attributeName, attributeValue)](#ElementService+setAttribute) ⇒ <code>undefined</code>
@@ -2233,6 +2401,29 @@ Not implemented yet (HTML parsing is out of scope for now).
2233
2401
  | position | <code>string</code> | beforebegin, afterbegin, beforeend or afterend |
2234
2402
  | text | <code>string</code> | The markup which would be parsed |
2235
2403
 
2404
+ <a name="ElementService+matches"></a>
2405
+
2406
+ ### elementService.matches(selectors) ⇒ <code>boolean</code>
2407
+ Whether this element itself (not its descendants) matches the given CSS selector.
2408
+
2409
+ **Kind**: instance method of [<code>ElementService</code>](#ElementService)
2410
+
2411
+ | Param | Type | Description |
2412
+ | --- | --- | --- |
2413
+ | selectors | <code>string</code> | A CSS selector |
2414
+
2415
+ <a name="ElementService+closest"></a>
2416
+
2417
+ ### elementService.closest(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
2418
+ The nearest ancestor of this element (starting with this element itself) which matches the CSS selector, or
2419
+ null when none of them do.
2420
+
2421
+ **Kind**: instance method of [<code>ElementService</code>](#ElementService)
2422
+
2423
+ | Param | Type | Description |
2424
+ | --- | --- | --- |
2425
+ | selectors | <code>string</code> | A CSS selector |
2426
+
2236
2427
  <a name="ElementService+childInserted"></a>
2237
2428
 
2238
2429
  ### elementService.childInserted(child)
@@ -2301,6 +2492,7 @@ Simulate the behaviour of the Document Class when there is no DOM available.
2301
2492
 
2302
2493
  * [DocumentService](#DocumentService) ⇐ [<code>NodeService</code>](#NodeService)
2303
2494
  * [.acceptsChildren](#NodeService+acceptsChildren) ⇒ <code>boolean</code>
2495
+ * [.getElementById(id)](#DocumentService+getElementById) ⇒ <code>PseudoElement</code> \| <code>null</code>
2304
2496
  * [.appendChild(childNode)](#NodeService+appendChild) ⇒ <code>PseudoNode</code>
2305
2497
  * [.cloneShallow()](#NodeService+cloneShallow) ⇒ [<code>NodeService</code>](#NodeService)
2306
2498
  * [.equalsShallow(other)](#NodeService+equalsShallow) ⇒ <code>boolean</code>
@@ -2312,6 +2504,10 @@ Simulate the behaviour of the Document Class when there is no DOM available.
2312
2504
  * [.replaceWith(...nodes)](#NodeService+replaceWith)
2313
2505
  * [.remove()](#NodeService+remove)
2314
2506
  * [.toChildNode(value)](#NodeService+toChildNode) ⇒ <code>PseudoNode</code>
2507
+ * [.getElementsByTagName(tagName)](#NodeService+getElementsByTagName) ⇒ <code>PseudoHTMLCollection</code>
2508
+ * [.getElementsByClassName(className)](#NodeService+getElementsByClassName) ⇒ <code>PseudoHTMLCollection</code>
2509
+ * [.querySelector(selectors)](#NodeService+querySelector) ⇒ <code>PseudoElement</code> \| <code>null</code>
2510
+ * [.querySelectorAll(selectors)](#NodeService+querySelectorAll) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
2315
2511
  * [.childInserted(child)](#NodeService+childInserted)
2316
2512
  * [.cloneNode([deep])](#NodeService+cloneNode) ⇒ <code>PseudoNode</code>
2317
2513
  * [.compareDocumentPosition(otherNode)](#NodeService+compareDocumentPosition) ⇒ <code>number</code>
@@ -2328,6 +2524,17 @@ Simulate the behaviour of the Document Class when there is no DOM available.
2328
2524
  Whether this kind of node can have children (text, comments and attributes cannot).
2329
2525
 
2330
2526
  **Kind**: instance property of [<code>DocumentService</code>](#DocumentService)
2527
+ <a name="DocumentService+getElementById"></a>
2528
+
2529
+ ### documentService.getElementById(id) ⇒ <code>PseudoElement</code> \| <code>null</code>
2530
+ The first element, in tree order, whose id matches the given value, or null when there is none.
2531
+
2532
+ **Kind**: instance method of [<code>DocumentService</code>](#DocumentService)
2533
+
2534
+ | Param | Type |
2535
+ | --- | --- |
2536
+ | id | <code>string</code> |
2537
+
2331
2538
  <a name="NodeService+appendChild"></a>
2332
2539
 
2333
2540
  ### documentService.appendChild(childNode) ⇒ <code>PseudoNode</code>
@@ -2458,6 +2665,51 @@ becomes a text node belonging to this node's document, anything else is returned
2458
2665
  | --- | --- | --- |
2459
2666
  | value | <code>PseudoNode</code> \| <code>string</code> | The value to add |
2460
2667
 
2668
+ <a name="NodeService+getElementsByTagName"></a>
2669
+
2670
+ ### documentService.getElementsByTagName(tagName) ⇒ <code>PseudoHTMLCollection</code>
2671
+ Every element below this node with the given tag name (or every element when tagName is *), live.
2672
+
2673
+ **Kind**: instance method of [<code>DocumentService</code>](#DocumentService)
2674
+
2675
+ | Param | Type |
2676
+ | --- | --- |
2677
+ | tagName | <code>string</code> |
2678
+
2679
+ <a name="NodeService+getElementsByClassName"></a>
2680
+
2681
+ ### documentService.getElementsByClassName(className) ⇒ <code>PseudoHTMLCollection</code>
2682
+ Every element below this node which has all of the given (space separated) classes, live.
2683
+
2684
+ **Kind**: instance method of [<code>DocumentService</code>](#DocumentService)
2685
+
2686
+ | Param | Type |
2687
+ | --- | --- |
2688
+ | className | <code>string</code> |
2689
+
2690
+ <a name="NodeService+querySelector"></a>
2691
+
2692
+ ### documentService.querySelector(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
2693
+ The first element below this node which matches the CSS selector, in tree order, or null when there is none.
2694
+
2695
+ **Kind**: instance method of [<code>DocumentService</code>](#DocumentService)
2696
+
2697
+ | Param | Type | Description |
2698
+ | --- | --- | --- |
2699
+ | selectors | <code>string</code> | A CSS selector |
2700
+
2701
+ <a name="NodeService+querySelectorAll"></a>
2702
+
2703
+ ### documentService.querySelectorAll(selectors) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
2704
+ Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
2705
+ collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
2706
+
2707
+ **Kind**: instance method of [<code>DocumentService</code>](#DocumentService)
2708
+
2709
+ | Param | Type | Description |
2710
+ | --- | --- | --- |
2711
+ | selectors | <code>string</code> | A CSS selector |
2712
+
2461
2713
  <a name="NodeService+childInserted"></a>
2462
2714
 
2463
2715
  ### documentService.childInserted(child)
@@ -2599,6 +2851,10 @@ not part of a tree, when it is inserted its children are moved into the tree ins
2599
2851
  * [.replaceWith(...nodes)](#NodeService+replaceWith)
2600
2852
  * [.remove()](#NodeService+remove)
2601
2853
  * [.toChildNode(value)](#NodeService+toChildNode) ⇒ <code>PseudoNode</code>
2854
+ * [.getElementsByTagName(tagName)](#NodeService+getElementsByTagName) ⇒ <code>PseudoHTMLCollection</code>
2855
+ * [.getElementsByClassName(className)](#NodeService+getElementsByClassName) ⇒ <code>PseudoHTMLCollection</code>
2856
+ * [.querySelector(selectors)](#NodeService+querySelector) ⇒ <code>PseudoElement</code> \| <code>null</code>
2857
+ * [.querySelectorAll(selectors)](#NodeService+querySelectorAll) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
2602
2858
  * [.childInserted(child)](#NodeService+childInserted)
2603
2859
  * [.cloneNode([deep])](#NodeService+cloneNode) ⇒ <code>PseudoNode</code>
2604
2860
  * [.compareDocumentPosition(otherNode)](#NodeService+compareDocumentPosition) ⇒ <code>number</code>
@@ -2745,6 +3001,51 @@ becomes a text node belonging to this node's document, anything else is returned
2745
3001
  | --- | --- | --- |
2746
3002
  | value | <code>PseudoNode</code> \| <code>string</code> | The value to add |
2747
3003
 
3004
+ <a name="NodeService+getElementsByTagName"></a>
3005
+
3006
+ ### documentFragmentService.getElementsByTagName(tagName) ⇒ <code>PseudoHTMLCollection</code>
3007
+ Every element below this node with the given tag name (or every element when tagName is *), live.
3008
+
3009
+ **Kind**: instance method of [<code>DocumentFragmentService</code>](#DocumentFragmentService)
3010
+
3011
+ | Param | Type |
3012
+ | --- | --- |
3013
+ | tagName | <code>string</code> |
3014
+
3015
+ <a name="NodeService+getElementsByClassName"></a>
3016
+
3017
+ ### documentFragmentService.getElementsByClassName(className) ⇒ <code>PseudoHTMLCollection</code>
3018
+ Every element below this node which has all of the given (space separated) classes, live.
3019
+
3020
+ **Kind**: instance method of [<code>DocumentFragmentService</code>](#DocumentFragmentService)
3021
+
3022
+ | Param | Type |
3023
+ | --- | --- |
3024
+ | className | <code>string</code> |
3025
+
3026
+ <a name="NodeService+querySelector"></a>
3027
+
3028
+ ### documentFragmentService.querySelector(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
3029
+ The first element below this node which matches the CSS selector, in tree order, or null when there is none.
3030
+
3031
+ **Kind**: instance method of [<code>DocumentFragmentService</code>](#DocumentFragmentService)
3032
+
3033
+ | Param | Type | Description |
3034
+ | --- | --- | --- |
3035
+ | selectors | <code>string</code> | A CSS selector |
3036
+
3037
+ <a name="NodeService+querySelectorAll"></a>
3038
+
3039
+ ### documentFragmentService.querySelectorAll(selectors) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
3040
+ Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
3041
+ collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
3042
+
3043
+ **Kind**: instance method of [<code>DocumentFragmentService</code>](#DocumentFragmentService)
3044
+
3045
+ | Param | Type | Description |
3046
+ | --- | --- | --- |
3047
+ | selectors | <code>string</code> | A CSS selector |
3048
+
2748
3049
  <a name="NodeService+childInserted"></a>
2749
3050
 
2750
3051
  ### documentFragmentService.childInserted(child)
@@ -2971,6 +3272,10 @@ Simulate the behaviour of the Attr Class when there is no DOM available.
2971
3272
  * [.replaceWith(...nodes)](#NodeService+replaceWith)
2972
3273
  * [.remove()](#NodeService+remove)
2973
3274
  * [.toChildNode(value)](#NodeService+toChildNode) ⇒ <code>PseudoNode</code>
3275
+ * [.getElementsByTagName(tagName)](#NodeService+getElementsByTagName) ⇒ <code>PseudoHTMLCollection</code>
3276
+ * [.getElementsByClassName(className)](#NodeService+getElementsByClassName) ⇒ <code>PseudoHTMLCollection</code>
3277
+ * [.querySelector(selectors)](#NodeService+querySelector) ⇒ <code>PseudoElement</code> \| <code>null</code>
3278
+ * [.querySelectorAll(selectors)](#NodeService+querySelectorAll) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
2974
3279
  * [.childInserted(child)](#NodeService+childInserted)
2975
3280
  * [.cloneNode([deep])](#NodeService+cloneNode) ⇒ <code>PseudoNode</code>
2976
3281
  * [.compareDocumentPosition(otherNode)](#NodeService+compareDocumentPosition) ⇒ <code>number</code>
@@ -3141,6 +3446,55 @@ becomes a text node belonging to this node's document, anything else is returned
3141
3446
  | --- | --- | --- |
3142
3447
  | value | <code>PseudoNode</code> \| <code>string</code> | The value to add |
3143
3448
 
3449
+ <a name="NodeService+getElementsByTagName"></a>
3450
+
3451
+ ### attrService.getElementsByTagName(tagName) ⇒ <code>PseudoHTMLCollection</code>
3452
+ Every element below this node with the given tag name (or every element when tagName is *), live.
3453
+
3454
+ **Kind**: instance method of [<code>AttrService</code>](#AttrService)
3455
+ **Overrides**: [<code>getElementsByTagName</code>](#NodeService+getElementsByTagName)
3456
+
3457
+ | Param | Type |
3458
+ | --- | --- |
3459
+ | tagName | <code>string</code> |
3460
+
3461
+ <a name="NodeService+getElementsByClassName"></a>
3462
+
3463
+ ### attrService.getElementsByClassName(className) ⇒ <code>PseudoHTMLCollection</code>
3464
+ Every element below this node which has all of the given (space separated) classes, live.
3465
+
3466
+ **Kind**: instance method of [<code>AttrService</code>](#AttrService)
3467
+ **Overrides**: [<code>getElementsByClassName</code>](#NodeService+getElementsByClassName)
3468
+
3469
+ | Param | Type |
3470
+ | --- | --- |
3471
+ | className | <code>string</code> |
3472
+
3473
+ <a name="NodeService+querySelector"></a>
3474
+
3475
+ ### attrService.querySelector(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
3476
+ The first element below this node which matches the CSS selector, in tree order, or null when there is none.
3477
+
3478
+ **Kind**: instance method of [<code>AttrService</code>](#AttrService)
3479
+ **Overrides**: [<code>querySelector</code>](#NodeService+querySelector)
3480
+
3481
+ | Param | Type | Description |
3482
+ | --- | --- | --- |
3483
+ | selectors | <code>string</code> | A CSS selector |
3484
+
3485
+ <a name="NodeService+querySelectorAll"></a>
3486
+
3487
+ ### attrService.querySelectorAll(selectors) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
3488
+ Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
3489
+ collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
3490
+
3491
+ **Kind**: instance method of [<code>AttrService</code>](#AttrService)
3492
+ **Overrides**: [<code>querySelectorAll</code>](#NodeService+querySelectorAll)
3493
+
3494
+ | Param | Type | Description |
3495
+ | --- | --- | --- |
3496
+ | selectors | <code>string</code> | A CSS selector |
3497
+
3144
3498
  <a name="NodeService+childInserted"></a>
3145
3499
 
3146
3500
  ### attrService.childInserted(child)
@@ -3292,6 +3646,10 @@ from that linker, and its parent from the linker's parent when it has not been g
3292
3646
  * [.replaceWith(...nodes)](#NodeService+replaceWith)
3293
3647
  * [.remove()](#NodeService+remove)
3294
3648
  * [.toChildNode(value)](#NodeService+toChildNode) ⇒ <code>PseudoNode</code>
3649
+ * [.getElementsByTagName(tagName)](#NodeService+getElementsByTagName) ⇒ <code>PseudoHTMLCollection</code>
3650
+ * [.getElementsByClassName(className)](#NodeService+getElementsByClassName) ⇒ <code>PseudoHTMLCollection</code>
3651
+ * [.querySelector(selectors)](#NodeService+querySelector) ⇒ <code>PseudoElement</code> \| <code>null</code>
3652
+ * [.querySelectorAll(selectors)](#NodeService+querySelectorAll) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
3295
3653
  * [.childInserted(child)](#NodeService+childInserted)
3296
3654
  * [.cloneNode([deep])](#NodeService+cloneNode) ⇒ <code>PseudoNode</code>
3297
3655
  * [.compareDocumentPosition(otherNode)](#NodeService+compareDocumentPosition) ⇒ <code>number</code>
@@ -3459,6 +3817,55 @@ becomes a text node belonging to this node's document, anything else is returned
3459
3817
  | --- | --- | --- |
3460
3818
  | value | <code>PseudoNode</code> \| <code>string</code> | The value to add |
3461
3819
 
3820
+ <a name="NodeService+getElementsByTagName"></a>
3821
+
3822
+ ### linkedNode.getElementsByTagName(tagName) ⇒ <code>PseudoHTMLCollection</code>
3823
+ Every element below this node with the given tag name (or every element when tagName is *), live.
3824
+
3825
+ **Kind**: instance method of [<code>LinkedNode</code>](#LinkedNode)
3826
+ **Overrides**: [<code>getElementsByTagName</code>](#NodeService+getElementsByTagName)
3827
+
3828
+ | Param | Type |
3829
+ | --- | --- |
3830
+ | tagName | <code>string</code> |
3831
+
3832
+ <a name="NodeService+getElementsByClassName"></a>
3833
+
3834
+ ### linkedNode.getElementsByClassName(className) ⇒ <code>PseudoHTMLCollection</code>
3835
+ Every element below this node which has all of the given (space separated) classes, live.
3836
+
3837
+ **Kind**: instance method of [<code>LinkedNode</code>](#LinkedNode)
3838
+ **Overrides**: [<code>getElementsByClassName</code>](#NodeService+getElementsByClassName)
3839
+
3840
+ | Param | Type |
3841
+ | --- | --- |
3842
+ | className | <code>string</code> |
3843
+
3844
+ <a name="NodeService+querySelector"></a>
3845
+
3846
+ ### linkedNode.querySelector(selectors) ⇒ <code>PseudoElement</code> \| <code>null</code>
3847
+ The first element below this node which matches the CSS selector, in tree order, or null when there is none.
3848
+
3849
+ **Kind**: instance method of [<code>LinkedNode</code>](#LinkedNode)
3850
+ **Overrides**: [<code>querySelector</code>](#NodeService+querySelector)
3851
+
3852
+ | Param | Type | Description |
3853
+ | --- | --- | --- |
3854
+ | selectors | <code>string</code> | A CSS selector |
3855
+
3856
+ <a name="NodeService+querySelectorAll"></a>
3857
+
3858
+ ### linkedNode.querySelectorAll(selectors) ⇒ <code>Array.&lt;PseudoElement&gt;</code>
3859
+ Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
3860
+ collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
3861
+
3862
+ **Kind**: instance method of [<code>LinkedNode</code>](#LinkedNode)
3863
+ **Overrides**: [<code>querySelectorAll</code>](#NodeService+querySelectorAll)
3864
+
3865
+ | Param | Type | Description |
3866
+ | --- | --- | --- |
3867
+ | selectors | <code>string</code> | A CSS selector |
3868
+
3462
3869
  <a name="NodeService+childInserted"></a>
3463
3870
 
3464
3871
  ### linkedNode.childInserted(child)
@@ -3998,6 +4405,18 @@ Create an instance of HTMLElement if not available
3998
4405
  Define document when not available
3999
4406
 
4000
4407
  **Kind**: inner constant of [<code>generateDocument</code>](#generateDocument)
4408
+ <a name="nearestElementSibling"></a>
4409
+
4410
+ ## nearestElementSibling(node, direction) ⇒ <code>\*</code> \| <code>null</code>
4411
+ Walk up from a node (not including it) to find the nearest element, in the given direction.
4412
+
4413
+ **Kind**: global function
4414
+
4415
+ | Param | Type | Description |
4416
+ | --- | --- | --- |
4417
+ | node | <code>\*</code> | The node to start from |
4418
+ | direction | <code>&#x27;nextSibling&#x27;</code> \| <code>&#x27;previousSibling&#x27;</code> | Which sibling reference to follow |
4419
+
4001
4420
  <a name="createEvent"></a>
4002
4421
 
4003
4422
  ## createEvent(type, [init], [options]) ⇒ [<code>EventService</code>](#EventService)