pseudo-dom 0.6.0 → 0.8.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 (131) hide show
  1. package/README.md +686 -241
  2. package/browser/pseudo-dom.js +3576 -735
  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 +17 -43
  7. package/dist/classes/PseudoHTMLDocument.js +24 -94
  8. package/dist/classes/PseudoHTMLDocument.min.js +1 -1
  9. package/dist/classes/PseudoNodeList.d.ts +34 -34
  10. package/dist/classes/PseudoNodeList.js +71 -71
  11. package/dist/factories/createEvent.d.ts +28 -28
  12. package/dist/factories/createEvent.js +56 -56
  13. package/dist/factories/cssSelectAdapter.d.ts +23 -0
  14. package/dist/factories/cssSelectAdapter.js +87 -0
  15. package/dist/factories/cssSelectAdapter.min.js +1 -0
  16. package/dist/factories/eventDefaults.d.ts +31 -31
  17. package/dist/factories/eventDefaults.js +105 -105
  18. package/dist/factories/generateDocument.d.ts +11 -11
  19. package/dist/factories/generateDocument.js +65 -65
  20. package/dist/factories/generateNodeList.d.ts +9 -9
  21. package/dist/factories/generateNodeList.js +13 -13
  22. package/dist/factories/query.d.ts +33 -0
  23. package/dist/factories/query.js +66 -0
  24. package/dist/factories/query.min.js +1 -0
  25. package/dist/functions/activeElement.d.ts +14 -14
  26. package/dist/functions/activeElement.js +33 -33
  27. package/dist/functions/getElementById.d.ts +13 -0
  28. package/dist/functions/getElementById.js +33 -0
  29. package/dist/functions/getElementById.min.js +1 -0
  30. package/dist/functions/getParentNodes.d.ts +11 -11
  31. package/dist/functions/getParentNodes.js +22 -22
  32. package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
  33. package/dist/functions/getParentNodesFromAttribute.js +29 -29
  34. package/dist/functions/modifierState.d.ts +29 -29
  35. package/dist/functions/modifierState.js +41 -41
  36. package/dist/interfaces/PseudoAnimation.d.ts +3 -3
  37. package/dist/interfaces/PseudoAnimation.js +5 -5
  38. package/dist/interfaces/PseudoAttr.d.ts +11 -11
  39. package/dist/interfaces/PseudoAttr.js +5 -5
  40. package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
  41. package/dist/interfaces/PseudoDOMTokenList.js +5 -5
  42. package/dist/interfaces/PseudoDocument.d.ts +32 -0
  43. package/dist/interfaces/PseudoDocument.js +5 -5
  44. package/dist/interfaces/PseudoDocumentFragment.d.ts +7 -0
  45. package/dist/interfaces/PseudoDocumentFragment.js +5 -5
  46. package/dist/interfaces/PseudoElement.d.ts +702 -689
  47. package/dist/interfaces/PseudoElement.js +5 -5
  48. package/dist/interfaces/PseudoEvent.d.ts +79 -79
  49. package/dist/interfaces/PseudoEvent.js +10 -10
  50. package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
  51. package/dist/interfaces/PseudoEventTarget.js +5 -5
  52. package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
  53. package/dist/interfaces/PseudoHTMLCollection.js +5 -5
  54. package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
  55. package/dist/interfaces/PseudoHTMLElement.js +5 -5
  56. package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
  57. package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
  58. package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
  59. package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
  60. package/dist/interfaces/PseudoNode.d.ts +179 -179
  61. package/dist/interfaces/PseudoNode.js +5 -5
  62. package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
  63. package/dist/interfaces/PseudoShadowRoot.js +5 -5
  64. package/dist/main.d.ts +63 -63
  65. package/dist/main.js +155 -155
  66. package/dist/services/AnimationService.d.ts +4 -4
  67. package/dist/services/AnimationService.js +16 -16
  68. package/dist/services/AttrService.d.ts +37 -37
  69. package/dist/services/AttrService.js +81 -81
  70. package/dist/services/CommentService.d.ts +1 -1
  71. package/dist/services/CommentService.js +13 -13
  72. package/dist/services/CustomEventService.d.ts +37 -37
  73. package/dist/services/CustomEventService.js +35 -35
  74. package/dist/services/DOMTokenListService.d.ts +33 -33
  75. package/dist/services/DOMTokenListService.js +117 -117
  76. package/dist/services/DocumentFragmentService.d.ts +8 -0
  77. package/dist/services/DocumentFragmentService.js +18 -0
  78. package/dist/services/DocumentFragmentService.min.js +1 -1
  79. package/dist/services/DocumentService.d.ts +35 -1
  80. package/dist/services/DocumentService.js +72 -0
  81. package/dist/services/DocumentService.min.js +1 -1
  82. package/dist/services/ElementService.d.ts +191 -178
  83. package/dist/services/ElementService.js +426 -406
  84. package/dist/services/ElementService.min.js +1 -1
  85. package/dist/services/EventService.d.ts +120 -120
  86. package/dist/services/EventService.js +250 -250
  87. package/dist/services/EventTargetService.d.ts +84 -84
  88. package/dist/services/EventTargetService.js +232 -232
  89. package/dist/services/FocusEventService.d.ts +32 -32
  90. package/dist/services/FocusEventService.js +35 -35
  91. package/dist/services/HTMLCollectionService.d.ts +54 -49
  92. package/dist/services/HTMLCollectionService.js +92 -75
  93. package/dist/services/HTMLCollectionService.min.js +1 -1
  94. package/dist/services/HTMLElementService.d.ts +57 -57
  95. package/dist/services/HTMLElementService.js +163 -163
  96. package/dist/services/HTMLSlotElementService.d.ts +4 -4
  97. package/dist/services/HTMLSlotElementService.js +9 -9
  98. package/dist/services/InputEventService.d.ts +41 -41
  99. package/dist/services/InputEventService.js +47 -47
  100. package/dist/services/KeyboardEventService.d.ts +70 -70
  101. package/dist/services/KeyboardEventService.js +86 -86
  102. package/dist/services/MouseEventService.d.ts +80 -80
  103. package/dist/services/MouseEventService.js +108 -108
  104. package/dist/services/NamedNodeMapService.d.ts +23 -23
  105. package/dist/services/NamedNodeMapService.js +77 -77
  106. package/dist/services/NodeService.d.ts +297 -271
  107. package/dist/services/NodeService.js +721 -679
  108. package/dist/services/NodeService.min.js +1 -1
  109. package/dist/services/PointerEventService.d.ts +51 -51
  110. package/dist/services/PointerEventService.js +67 -67
  111. package/dist/services/ShadowRootService.d.ts +4 -4
  112. package/dist/services/ShadowRootService.js +9 -9
  113. package/dist/services/TextService.d.ts +1 -1
  114. package/dist/services/TextService.js +13 -13
  115. package/dist/services/UIEventService.d.ts +43 -43
  116. package/dist/services/UIEventService.js +42 -42
  117. package/dist/simulate.d.ts +32 -32
  118. package/dist/simulate.js +115 -115
  119. package/package.json +4 -3
  120. package/dist/classes.d.ts +0 -20
  121. package/dist/classes.js +0 -31
  122. package/dist/classes.min.js +0 -1
  123. package/dist/factories/generateNode.d.ts +0 -32
  124. package/dist/factories/generateNode.js +0 -85
  125. package/dist/factories/generateNode.min.js +0 -1
  126. package/dist/factories.d.ts +0 -11
  127. package/dist/factories.js +0 -27
  128. package/dist/factories.min.js +0 -1
  129. package/dist/functions.d.ts +0 -5
  130. package/dist/functions.js +0 -23
  131. package/dist/functions.min.js +0 -1
@@ -2,137 +2,67 @@
2
2
 
3
3
  require('core-js/modules/esnext.iterator.constructor.js')
4
4
  require('core-js/modules/esnext.iterator.find.js')
5
- require('core-js/modules/esnext.iterator.for-each.js')
6
5
  Object.defineProperty(exports, '__esModule', {
7
6
  value: true
8
7
  })
8
+ const DocumentService_1 = require('../services/DocumentService')
9
9
  /**
10
- * @file Substitute for the DOM HTMLDocument Class.
11
- * @author Joshua Heagle <joshuaheagle@gmail.com>
12
- * @version 1.0.0
13
- */
14
- /**
15
- *
16
- * @type {PseudoHTMLElement}
17
- */
18
- const HTMLElementService_1 = require('../services/HTMLElementService')
19
- const NodeService_1 = require('../services/NodeService')
20
- const DocumentFragmentService_1 = require('../services/DocumentFragmentService')
21
- /**
22
- * Simulate the behaviour of the HTMLDocument Class when there is no DOM available.
10
+ * Simulate the behaviour of the HTMLDocument Class when there is no DOM available. Like the real HTMLDocument, this
11
+ * only adds the html/head/body structure on top of what Document already gives (createElement, createTextNode,
12
+ * createComment, createDocumentFragment, getElementById, textContent always null).
23
13
  * @author Joshua Heagle <joshuaheagle@gmail.com>
24
14
  * @class
25
- * @augments PseudoHTMLElement
15
+ * @augments DocumentService
26
16
  * @property {PseudoHTMLElement} head - A reference to the Head child element
27
17
  * @property {PseudoHTMLElement} body - A reference to the Body child element
28
- * @property {function} createElement - Generate a new PseudoHTMLElement (which is not in the document until it is appended)
29
18
  */
30
- class PseudoHTMLDocument extends HTMLElementService_1.HTMLElementService {
19
+ class PseudoHTMLDocument extends DocumentService_1.DocumentService {
31
20
  /**
32
21
  * The root HTML element is acts as the parent to all HTML elements in the document.
33
22
  * @constructor
34
23
  */
35
24
  constructor () {
36
25
  super()
37
- const html = new HTMLElementService_1.HTMLElementService({
38
- tagName: 'html'
39
- })
26
+ const html = this.createElement('html')
40
27
  this.appendChild(html)
41
28
  /**
42
29
  * Create document head element
43
30
  * @type {PseudoHTMLElement}
44
31
  */
45
- this.head = new HTMLElementService_1.HTMLElementService({
46
- tagName: 'head'
47
- })
32
+ this.head = this.createElement('head')
48
33
  html.appendChild(this.head)
49
34
  /**
50
35
  * Create document body element
51
36
  * @type {PseudoHTMLElement}
52
37
  */
53
- this.body = new HTMLElementService_1.HTMLElementService({
54
- tagName: 'body'
55
- })
38
+ this.body = this.createElement('body')
56
39
  html.appendChild(this.body)
57
40
  }
58
41
 
59
- get nodeName () {
60
- return '#document'
61
- }
62
-
63
- get nodeType () {
64
- return NodeService_1.NodeService.DOCUMENT_NODE
65
- }
66
-
67
- // A document has no text of its own, and setting it does nothing
68
- get textContent () {
69
- return null
70
- }
71
-
72
- set textContent (text) {}
73
- /**
74
- * Make an element of the given type which belongs to this document but is not added anywhere until it is appended.
75
- * @param {string} tagName - Tag Name is a string representing the type of Dom element this represents
76
- * @returns {PseudoHTMLElement}
77
- */
78
- createElement (tagName = 'div') {
79
- // Like the DOM, the new element is not added anywhere: it has no parent until it is appended
80
- const element = new HTMLElementService_1.HTMLElementService({
81
- tagName
82
- })
83
- element.ownerDocumentStore = this
84
- return element
85
- }
86
-
87
- /**
88
- * Make a text node which belongs to this document.
89
- * @param {string} [data=''] The text
90
- * @returns {TextService}
91
- */
92
- createTextNode (data = '') {
93
- const text = new NodeService_1.TextService(data)
94
- text.ownerDocumentStore = this
95
- return text
96
- }
97
-
98
42
  /**
99
- * Make a comment which belongs to this document.
100
- * @param {string} [data=''] The comment
101
- * @returns {CommentService}
43
+ * A copy of this document with none of its html/head/body (cloneNode, from the inherited cloneShallow hook, fills
44
+ * them back in, deep copies own document's, empty otherwise - see cloneNode).
45
+ * @returns {PseudoHTMLDocument}
102
46
  */
103
- createComment (data = '') {
104
- const comment = new NodeService_1.CommentService(data)
105
- comment.ownerDocumentStore = this
106
- return comment
107
- }
108
-
109
- /**
110
- * Make an empty document fragment which belongs to this document, a container for nodes which can be built up and
111
- * then inserted in one go.
112
- * @returns {DocumentFragmentService}
113
- */
114
- createDocumentFragment () {
115
- const fragment = new DocumentFragmentService_1.DocumentFragmentService()
116
- fragment.ownerDocumentStore = this
117
- return fragment
47
+ cloneShallow () {
48
+ const copy = new this.constructor()
49
+ while (copy.firstChild) {
50
+ copy.removeChild(copy.firstChild)
51
+ }
52
+ copy.head = null
53
+ copy.body = null
54
+ return copy
118
55
  }
119
56
 
120
57
  /**
121
- * Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in the
122
- * document (a shallow one is an empty document).
58
+ * Make a copy of this document. The copy has no parent or listeners, and a deep copy has copies of everything in
59
+ * the document (a shallow one is an empty document).
123
60
  * @param {boolean} [deep=false] Copy everything in the document as well
124
- * @returns {PseudoNode}
61
+ * @returns {PseudoHTMLDocument}
125
62
  */
126
63
  cloneNode (deep = false) {
127
- const copy = new PseudoHTMLDocument()
128
- // The new document starts out with its own html, head and body, a copy has only what was copied from this one
129
- while (copy.firstChild) {
130
- copy.removeChild(copy.firstChild)
131
- }
132
- copy.head = null
133
- copy.body = null
64
+ const copy = super.cloneNode(deep)
134
65
  if (deep) {
135
- Array.from(this.childNodes).forEach(child => copy.appendChild(child.cloneNode(true)))
136
66
  const html = Array.from(copy.childNodes).find(child => child.tagName === 'html')
137
67
  const inHtml = tagName => html ? Array.from(html.childNodes).find(child => child.tagName === tagName) || null : null
138
68
  copy.head = inHtml('head')
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.find.js"),require("core-js/modules/esnext.iterator.for-each.js"),Object.defineProperty(exports,"__esModule",{value:!0});const HTMLElementService_1=require("../services/HTMLElementService"),NodeService_1=require("../services/NodeService"),DocumentFragmentService_1=require("../services/DocumentFragmentService");class PseudoHTMLDocument extends HTMLElementService_1.HTMLElementService{constructor(){super();const e=new HTMLElementService_1.HTMLElementService({tagName:"html"});this.appendChild(e),this.head=new HTMLElementService_1.HTMLElementService({tagName:"head"}),e.appendChild(this.head),this.body=new HTMLElementService_1.HTMLElementService({tagName:"body"}),e.appendChild(this.body)}get nodeName(){return"#document"}get nodeType(){return NodeService_1.NodeService.DOCUMENT_NODE}get textContent(){return null}set textContent(e){}createElement(e="div"){const t=new HTMLElementService_1.HTMLElementService({tagName:e});return t.ownerDocumentStore=this,t}createTextNode(e=""){const t=new NodeService_1.TextService(e);return t.ownerDocumentStore=this,t}createComment(e=""){const t=new NodeService_1.CommentService(e);return t.ownerDocumentStore=this,t}createDocumentFragment(){const e=new DocumentFragmentService_1.DocumentFragmentService;return e.ownerDocumentStore=this,e}cloneNode(e=!1){const t=new PseudoHTMLDocument;for(;t.firstChild;)t.removeChild(t.firstChild);if(t.head=null,t.body=null,e){Array.from(this.childNodes).forEach(e=>t.appendChild(e.cloneNode(!0)));const e=Array.from(t.childNodes).find(e=>"html"===e.tagName),r=t=>e&&Array.from(e.childNodes).find(e=>e.tagName===t)||null;t.head=r("head"),t.body=r("body")}return t}}exports.default=PseudoHTMLDocument;
1
+ "use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.find.js"),Object.defineProperty(exports,"__esModule",{value:!0});const DocumentService_1=require("../services/DocumentService");class PseudoHTMLDocument extends DocumentService_1.DocumentService{constructor(){super();const e=this.createElement("html");this.appendChild(e),this.head=this.createElement("head"),e.appendChild(this.head),this.body=this.createElement("body"),e.appendChild(this.body)}cloneShallow(){const e=new this.constructor;for(;e.firstChild;)e.removeChild(e.firstChild);return e.head=null,e.body=null,e}cloneNode(e=!1){const t=super.cloneNode(e);if(e){const e=Array.from(t.childNodes).find(e=>"html"===e.tagName),o=t=>e&&Array.from(e.childNodes).find(e=>e.tagName===t)||null;t.head=o("head"),t.body=o("body")}return t}}exports.default=PseudoHTMLDocument;
@@ -1,34 +1,34 @@
1
- /**
2
- * @file Substitute for the NodeList interface.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
5
- */
6
- import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
7
- /**
8
- * A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
9
- * the linkers that hold them.
10
- * @class
11
- * @augments LinkedTreeList
12
- */
13
- export declare class PseudoNodeList extends LinkedTreeList {
14
- /**
15
- * Iterate over the nodes in this list.
16
- * @returns {Iterator}
17
- */
18
- [Symbol.iterator](): Iterator<any>;
19
- /**
20
- * Iterate over [index, node] pairs.
21
- * @returns {Iterator}
22
- */
23
- entries(): Iterator<[number, any]>;
24
- /**
25
- * Iterate over the indexes.
26
- * @returns {Iterator}
27
- */
28
- keys(): Iterator<number>;
29
- /**
30
- * Iterate over the nodes.
31
- * @returns {Iterator}
32
- */
33
- values(): Iterator<any>;
34
- }
1
+ /**
2
+ * @file Substitute for the NodeList interface.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ */
6
+ import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
7
+ /**
8
+ * A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
9
+ * the linkers that hold them.
10
+ * @class
11
+ * @augments LinkedTreeList
12
+ */
13
+ export declare class PseudoNodeList extends LinkedTreeList {
14
+ /**
15
+ * Iterate over the nodes in this list.
16
+ * @returns {Iterator}
17
+ */
18
+ [Symbol.iterator](): Iterator<any>;
19
+ /**
20
+ * Iterate over [index, node] pairs.
21
+ * @returns {Iterator}
22
+ */
23
+ entries(): Iterator<[number, any]>;
24
+ /**
25
+ * Iterate over the indexes.
26
+ * @returns {Iterator}
27
+ */
28
+ keys(): Iterator<number>;
29
+ /**
30
+ * Iterate over the nodes.
31
+ * @returns {Iterator}
32
+ */
33
+ values(): Iterator<any>;
34
+ }
@@ -1,71 +1,71 @@
1
- 'use strict'
2
-
3
- require('core-js/modules/esnext.iterator.constructor.js')
4
- require('core-js/modules/esnext.iterator.map.js')
5
- Object.defineProperty(exports, '__esModule', {
6
- value: true
7
- })
8
- exports.PseudoNodeList = void 0
9
- /**
10
- * @file Substitute for the NodeList interface.
11
- * @author Joshua Heagle <joshuaheagle@gmail.com>
12
- * @version 1.0.0
13
- */
14
- const LinkedTreeList_1 = require('collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList')
15
- /**
16
- * A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
17
- * the linkers that hold them.
18
- * @class
19
- * @augments LinkedTreeList
20
- */
21
- class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
22
- /**
23
- * Iterate over the nodes in this list.
24
- * @returns {Iterator}
25
- */
26
- [Symbol.iterator] () {
27
- // Walk the nodes of this list only (the linkers of a child list have no children of their own)
28
- let current = this.first
29
- return {
30
- next: () => {
31
- if (current === null) {
32
- return {
33
- done: true,
34
- value: undefined
35
- }
36
- }
37
- const result = {
38
- done: false,
39
- value: current.data
40
- }
41
- current = current.next
42
- return result
43
- }
44
- }
45
- }
46
-
47
- /**
48
- * Iterate over [index, node] pairs.
49
- * @returns {Iterator}
50
- */
51
- entries () {
52
- return Array.from(this).map((node, index) => [index, node])[Symbol.iterator]()
53
- }
54
-
55
- /**
56
- * Iterate over the indexes.
57
- * @returns {Iterator}
58
- */
59
- keys () {
60
- return Array.from(this).map((node, index) => index)[Symbol.iterator]()
61
- }
62
-
63
- /**
64
- * Iterate over the nodes.
65
- * @returns {Iterator}
66
- */
67
- values () {
68
- return Array.from(this)[Symbol.iterator]()
69
- }
70
- }
71
- exports.PseudoNodeList = PseudoNodeList
1
+ 'use strict'
2
+
3
+ require('core-js/modules/esnext.iterator.constructor.js')
4
+ require('core-js/modules/esnext.iterator.map.js')
5
+ Object.defineProperty(exports, '__esModule', {
6
+ value: true
7
+ })
8
+ exports.PseudoNodeList = void 0
9
+ /**
10
+ * @file Substitute for the NodeList interface.
11
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
12
+ * @version 1.0.0
13
+ */
14
+ const LinkedTreeList_1 = require('collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList')
15
+ /**
16
+ * A NodeList, like the DOM one, iterates over the nodes themselves (the data stored in each TreeLinker), rather than
17
+ * the linkers that hold them.
18
+ * @class
19
+ * @augments LinkedTreeList
20
+ */
21
+ class PseudoNodeList extends LinkedTreeList_1.LinkedTreeList {
22
+ /**
23
+ * Iterate over the nodes in this list.
24
+ * @returns {Iterator}
25
+ */
26
+ [Symbol.iterator] () {
27
+ // Walk the nodes of this list only (the linkers of a child list have no children of their own)
28
+ let current = this.first
29
+ return {
30
+ next: () => {
31
+ if (current === null) {
32
+ return {
33
+ done: true,
34
+ value: undefined
35
+ }
36
+ }
37
+ const result = {
38
+ done: false,
39
+ value: current.data
40
+ }
41
+ current = current.next
42
+ return result
43
+ }
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Iterate over [index, node] pairs.
49
+ * @returns {Iterator}
50
+ */
51
+ entries () {
52
+ return Array.from(this).map((node, index) => [index, node])[Symbol.iterator]()
53
+ }
54
+
55
+ /**
56
+ * Iterate over the indexes.
57
+ * @returns {Iterator}
58
+ */
59
+ keys () {
60
+ return Array.from(this).map((node, index) => index)[Symbol.iterator]()
61
+ }
62
+
63
+ /**
64
+ * Iterate over the nodes.
65
+ * @returns {Iterator}
66
+ */
67
+ values () {
68
+ return Array.from(this)[Symbol.iterator]()
69
+ }
70
+ }
71
+ exports.PseudoNodeList = PseudoNodeList
@@ -1,28 +1,28 @@
1
- import { EventService } from '../services/EventService';
2
- /**
3
- * How the event is being created.
4
- * @typedef {Object} CreateEventOptions
5
- * @property {boolean} [browser=false] The browser is creating the event (for a user action, or for something like
6
- * element.click()), so the standard options for the type of event apply where the init does not give its own
7
- * @property {boolean} [trusted=false] The event comes from a real user action rather than from a script (isTrusted)
8
- */
9
- export type CreateEventOptions = {
10
- browser?: boolean;
11
- trusted?: boolean;
12
- };
13
- /**
14
- * Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
15
- * By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
16
- * the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
17
- * it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
18
- * real user action (isTrusted).
19
- * @function createEvent
20
- * @param {string} type The type of the event, such as click
21
- * @param {Object} [init={}] The options for the event (bubbles, cancelable, composed and those of its kind of event)
22
- * @param {CreateEventOptions} [options={}] Whether the browser is creating the event, and whether it is trusted
23
- * @returns {EventService}
24
- */
25
- export declare const createEvent: (type: string, init?: {
26
- [option: string]: any;
27
- }, { browser, trusted }?: CreateEventOptions) => EventService;
28
- export default createEvent;
1
+ import { EventService } from '../services/EventService';
2
+ /**
3
+ * How the event is being created.
4
+ * @typedef {Object} CreateEventOptions
5
+ * @property {boolean} [browser=false] The browser is creating the event (for a user action, or for something like
6
+ * element.click()), so the standard options for the type of event apply where the init does not give its own
7
+ * @property {boolean} [trusted=false] The event comes from a real user action rather than from a script (isTrusted)
8
+ */
9
+ export type CreateEventOptions = {
10
+ browser?: boolean;
11
+ trusted?: boolean;
12
+ };
13
+ /**
14
+ * Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
15
+ * By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
16
+ * the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
17
+ * it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
18
+ * real user action (isTrusted).
19
+ * @function createEvent
20
+ * @param {string} type The type of the event, such as click
21
+ * @param {Object} [init={}] The options for the event (bubbles, cancelable, composed and those of its kind of event)
22
+ * @param {CreateEventOptions} [options={}] Whether the browser is creating the event, and whether it is trusted
23
+ * @returns {EventService}
24
+ */
25
+ export declare const createEvent: (type: string, init?: {
26
+ [option: string]: any;
27
+ }, { browser, trusted }?: CreateEventOptions) => EventService;
28
+ export default createEvent;
@@ -1,56 +1,56 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.createEvent = void 0
7
- const EventService_1 = require('../services/EventService')
8
- const UIEventService_1 = require('../services/UIEventService')
9
- const MouseEventService_1 = require('../services/MouseEventService')
10
- const PointerEventService_1 = require('../services/PointerEventService')
11
- const KeyboardEventService_1 = require('../services/KeyboardEventService')
12
- const FocusEventService_1 = require('../services/FocusEventService')
13
- const InputEventService_1 = require('../services/InputEventService')
14
- const CustomEventService_1 = require('../services/CustomEventService')
15
- const eventDefaults_1 = require('./eventDefaults')
16
- const eventClasses = {
17
- Event: EventService_1.EventService,
18
- UIEvent: UIEventService_1.UIEventService,
19
- MouseEvent: MouseEventService_1.MouseEventService,
20
- PointerEvent: PointerEventService_1.PointerEventService,
21
- KeyboardEvent: KeyboardEventService_1.KeyboardEventService,
22
- FocusEvent: FocusEventService_1.FocusEventService,
23
- InputEvent: InputEventService_1.InputEventService,
24
- CustomEvent: CustomEventService_1.CustomEventService
25
- }
26
- /**
27
- * Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
28
- * By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
29
- * the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
30
- * it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
31
- * real user action (isTrusted).
32
- * @function createEvent
33
- * @param {string} type The type of the event, such as click
34
- * @param {Object} [init={}] The options for the event (bubbles, cancelable, composed and those of its kind of event)
35
- * @param {CreateEventOptions} [options={}] Whether the browser is creating the event, and whether it is trusted
36
- * @returns {EventService}
37
- */
38
- const createEvent = (type, init = {}, {
39
- browser = false,
40
- trusted = false
41
- } = {}) => {
42
- const definition = eventDefaults_1.eventDefaults[type]
43
- const options = browser && definition
44
- ? Object.assign({
45
- bubbles: definition.bubbles,
46
- cancelable: definition.cancelable,
47
- composed: definition.composed
48
- }, init)
49
- : init
50
- const EventClass = eventClasses[definition ? definition.interface : 'Event']
51
- const event = new EventClass(type, options)
52
- event.inner.trusted = trusted
53
- return event
54
- }
55
- exports.createEvent = createEvent
56
- exports.default = exports.createEvent
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.createEvent = void 0
7
+ const EventService_1 = require('../services/EventService')
8
+ const UIEventService_1 = require('../services/UIEventService')
9
+ const MouseEventService_1 = require('../services/MouseEventService')
10
+ const PointerEventService_1 = require('../services/PointerEventService')
11
+ const KeyboardEventService_1 = require('../services/KeyboardEventService')
12
+ const FocusEventService_1 = require('../services/FocusEventService')
13
+ const InputEventService_1 = require('../services/InputEventService')
14
+ const CustomEventService_1 = require('../services/CustomEventService')
15
+ const eventDefaults_1 = require('./eventDefaults')
16
+ const eventClasses = {
17
+ Event: EventService_1.EventService,
18
+ UIEvent: UIEventService_1.UIEventService,
19
+ MouseEvent: MouseEventService_1.MouseEventService,
20
+ PointerEvent: PointerEventService_1.PointerEventService,
21
+ KeyboardEvent: KeyboardEventService_1.KeyboardEventService,
22
+ FocusEvent: FocusEventService_1.FocusEventService,
23
+ InputEvent: InputEventService_1.InputEventService,
24
+ CustomEvent: CustomEventService_1.CustomEventService
25
+ }
26
+ /**
27
+ * Create an event of the kind which suits its type (a click is a MouseEvent, a keydown a KeyboardEvent, ...).
28
+ * By default this is like using the constructor of the event in a script: nothing bubbles or can be cancelled unless
29
+ * the init says so, and the event is not trusted. With browser: true the event is created the way the browser creates
30
+ * it, using the standard options for its type (see eventDefaults), and trusted: true makes it look like it came from a
31
+ * real user action (isTrusted).
32
+ * @function createEvent
33
+ * @param {string} type The type of the event, such as click
34
+ * @param {Object} [init={}] The options for the event (bubbles, cancelable, composed and those of its kind of event)
35
+ * @param {CreateEventOptions} [options={}] Whether the browser is creating the event, and whether it is trusted
36
+ * @returns {EventService}
37
+ */
38
+ const createEvent = (type, init = {}, {
39
+ browser = false,
40
+ trusted = false
41
+ } = {}) => {
42
+ const definition = eventDefaults_1.eventDefaults[type]
43
+ const options = browser && definition
44
+ ? Object.assign({
45
+ bubbles: definition.bubbles,
46
+ cancelable: definition.cancelable,
47
+ composed: definition.composed
48
+ }, init)
49
+ : init
50
+ const EventClass = eventClasses[definition ? definition.interface : 'Event']
51
+ const event = new EventClass(type, options)
52
+ event.inner.trusted = trusted
53
+ return event
54
+ }
55
+ exports.createEvent = createEvent
56
+ exports.default = exports.createEvent
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Maps pseudo-dom's own Node / Element API onto the Adapter interface css-select needs to query a tree which is not
3
+ * domutils' own (css-select's own Adapter<Node, ElementNode> type). Every method here is one pseudo-dom already has
4
+ * under a different name; nothing here reimplements DOM behaviour.
5
+ * @memberOf module:factories
6
+ * @type {Object}
7
+ */
8
+ export declare const cssSelectAdapter: {
9
+ isTag: (node: any) => boolean;
10
+ existsOne: (test: (elem: any) => boolean, elems: Array<any>) => boolean;
11
+ getAttributeValue: (elem: any, name: string) => string | undefined;
12
+ getChildren: (node: any) => Array<any>;
13
+ getName: (elem: any) => string;
14
+ getParent: (node: any) => any | null;
15
+ getSiblings: (node: any) => Array<any>;
16
+ prevElementSibling: (node: any) => any | null;
17
+ getText: (node: any) => string;
18
+ hasAttrib: (elem: any, name: string) => boolean;
19
+ removeSubsets: (nodes: Array<any>) => Array<any>;
20
+ findAll: (test: (elem: any) => boolean, nodes: Array<any>) => Array<any>;
21
+ findOne: (test: (elem: any) => boolean, nodes: Array<any>) => any | null;
22
+ };
23
+ export default cssSelectAdapter;