happy-dom 17.1.3 → 17.1.5

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.
@@ -3,8 +3,12 @@ import * as PropertySymbol from '../PropertySymbol.js';
3
3
  import INodeFilter from './INodeFilter.js';
4
4
  /**
5
5
  * The TreeWalker object represents the nodes of a document subtree and a position within them.
6
+ *
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
8
+ * @see https://dom.spec.whatwg.org/#interface-treewalker
6
9
  */
7
10
  export default class TreeWalker {
11
+ #private;
8
12
  root: Node;
9
13
  whatToShow: number;
10
14
  filter: INodeFilter;
@@ -17,18 +21,6 @@ export default class TreeWalker {
17
21
  * @param [filter] Filter.
18
22
  */
19
23
  constructor(root: Node, whatToShow?: number, filter?: INodeFilter);
20
- /**
21
- * Moves the current Node to the next visible node in the document order.
22
- *
23
- * @returns Current node.
24
- */
25
- nextNode(): Node;
26
- /**
27
- * Moves the current Node to the previous visible node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.
28
- *
29
- * @returns Current node.
30
- */
31
- previousNode(): Node;
32
24
  /**
33
25
  * Moves the current Node to the first visible ancestor node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.
34
26
  *
@@ -47,6 +39,12 @@ export default class TreeWalker {
47
39
  * @returns Current node.
48
40
  */
49
41
  lastChild(): Node;
42
+ /**
43
+ * Moves the current Node to its next sibling, if any, and returns the found sibling. If there is no such node, null is returned and the current node is not changed.
44
+ *
45
+ * @returns Current node.
46
+ */
47
+ nextSibling(): Node;
50
48
  /**
51
49
  * Moves the current Node to its previous sibling, if any, and returns the found sibling. If there is no such node, return null and the current node is not changed.
52
50
  *
@@ -54,11 +52,17 @@ export default class TreeWalker {
54
52
  */
55
53
  previousSibling(): Node;
56
54
  /**
57
- * Moves the current Node to its next sibling, if any, and returns the found sibling. If there is no such node, null is returned and the current node is not changed.
55
+ * Moves the current Node to the previous visible node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.
58
56
  *
59
57
  * @returns Current node.
60
58
  */
61
- nextSibling(): Node;
59
+ previousNode(): Node;
60
+ /**
61
+ * Moves the current Node to the next visible node in the document order.
62
+ *
63
+ * @returns Current node.
64
+ */
65
+ nextNode(): Node | null;
62
66
  /**
63
67
  * Filters a node.
64
68
  *
@@ -1 +1 @@
1
- {"version":3,"file":"TreeWalker.d.ts","sourceRoot":"","sources":["../../src/tree-walker/TreeWalker.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,uBAAuB,CAAC;AACzC,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAK3C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IACvB,IAAI,EAAE,IAAI,CAAQ;IAClB,UAAU,SAAM;IAChB,MAAM,EAAE,WAAW,CAAQ;IAC3B,WAAW,EAAE,IAAI,CAAQ;IAEhC;;;;;;OAMG;gBACS,IAAI,EAAE,IAAI,EAAE,UAAU,SAAK,EAAE,MAAM,GAAE,WAAkB;IAWnE;;;;OAIG;IACI,QAAQ,IAAI,IAAI;IAQvB;;;;OAIG;IACI,YAAY,IAAI,IAAI;IAM3B;;;;OAIG;IACI,UAAU,IAAI,IAAI;IAoBzB;;;;OAIG;IACI,UAAU,IAAI,IAAI;IAgBzB;;;;OAIG;IACI,SAAS,IAAI,IAAI;IAgBxB;;;;OAIG;IACI,eAAe,IAAI,IAAI;IAyB9B;;;;OAIG;IACI,WAAW,IAAI,IAAI;IAyB1B;;;;;;;;OAQG;IACI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;CAetD"}
1
+ {"version":3,"file":"TreeWalker.d.ts","sourceRoot":"","sources":["../../src/tree-walker/TreeWalker.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,uBAAuB,CAAC;AACzC,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAe3C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;;IACvB,IAAI,EAAE,IAAI,CAAQ;IAClB,UAAU,SAAM;IAChB,MAAM,EAAE,WAAW,CAAQ;IAC3B,WAAW,EAAE,IAAI,CAAQ;IAEhC;;;;;;OAMG;gBACS,IAAI,EAAE,IAAI,EAAE,UAAU,SAAK,EAAE,MAAM,GAAE,WAAkB;IAWnE;;;;OAIG;IACI,UAAU,IAAI,IAAI;IAYzB;;;;OAIG;IACI,UAAU,IAAI,IAAI;IAIzB;;;;OAIG;IACI,SAAS,IAAI,IAAI;IAIxB;;;;OAIG;IACI,WAAW,IAAI,IAAI;IAI1B;;;;OAIG;IACI,eAAe,IAAI,IAAI;IAI9B;;;;OAIG;IACI,YAAY,IAAI,IAAI;IAsC3B;;;;OAIG;IACI,QAAQ,IAAI,IAAI,GAAG,IAAI;IA2C9B;;;;;;;;OAQG;IACI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;CA0GtD"}
@@ -3,8 +3,21 @@ import * as PropertySymbol from '../PropertySymbol.js';
3
3
  import NodeFilterMask from './NodeFilterMask.js';
4
4
  import DOMException from '../exception/DOMException.js';
5
5
  import NodeFilter from './NodeFilter.js';
6
+ var TraverseChildrenTypeEnum;
7
+ (function (TraverseChildrenTypeEnum) {
8
+ TraverseChildrenTypeEnum["first"] = "first";
9
+ TraverseChildrenTypeEnum["last"] = "last";
10
+ })(TraverseChildrenTypeEnum || (TraverseChildrenTypeEnum = {}));
11
+ var TraverseSiblingsTypeEnum;
12
+ (function (TraverseSiblingsTypeEnum) {
13
+ TraverseSiblingsTypeEnum["next"] = "next";
14
+ TraverseSiblingsTypeEnum["previous"] = "previous";
15
+ })(TraverseSiblingsTypeEnum || (TraverseSiblingsTypeEnum = {}));
6
16
  /**
7
17
  * The TreeWalker object represents the nodes of a document subtree and a position within them.
18
+ *
19
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
20
+ * @see https://dom.spec.whatwg.org/#interface-treewalker
8
21
  */
9
22
  export default class TreeWalker {
10
23
  root = null;
@@ -27,44 +40,20 @@ export default class TreeWalker {
27
40
  this.filter = filter;
28
41
  this.currentNode = root;
29
42
  }
30
- /**
31
- * Moves the current Node to the next visible node in the document order.
32
- *
33
- * @returns Current node.
34
- */
35
- nextNode() {
36
- if (!this.firstChild()) {
37
- while (!this.nextSibling() && this.parentNode()) { }
38
- this.currentNode = this.currentNode === this.root ? null : this.currentNode || null;
39
- }
40
- return this.currentNode;
41
- }
42
- /**
43
- * Moves the current Node to the previous visible node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.
44
- *
45
- * @returns Current node.
46
- */
47
- previousNode() {
48
- while (!this.previousSibling() && this.parentNode()) { }
49
- this.currentNode = this.currentNode === this.root ? null : this.currentNode || null;
50
- return this.currentNode;
51
- }
52
43
  /**
53
44
  * Moves the current Node to the first visible ancestor node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.
54
45
  *
55
46
  * @returns Current node.
56
47
  */
57
48
  parentNode() {
58
- if (this.currentNode !== this.root &&
59
- this.currentNode &&
60
- this.currentNode[PropertySymbol.parentNode]) {
61
- this.currentNode = this.currentNode[PropertySymbol.parentNode];
62
- if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
49
+ let node = this.currentNode;
50
+ while (node !== null && node !== this.root) {
51
+ node = node.parentNode;
52
+ if (node !== null && this[PropertySymbol.filterNode](node) === NodeFilter.FILTER_ACCEPT) {
53
+ this.currentNode = node;
63
54
  return this.currentNode;
64
55
  }
65
- this.parentNode();
66
56
  }
67
- this.currentNode = null;
68
57
  return null;
69
58
  }
70
59
  /**
@@ -73,15 +62,7 @@ export default class TreeWalker {
73
62
  * @returns Current node.
74
63
  */
75
64
  firstChild() {
76
- const childNodes = this.currentNode ? this.currentNode[PropertySymbol.nodeArray] : [];
77
- if (childNodes.length > 0) {
78
- this.currentNode = childNodes[0];
79
- if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
80
- return this.currentNode;
81
- }
82
- return this.nextSibling();
83
- }
84
- return null;
65
+ return this.#traverseChildren(TraverseChildrenTypeEnum.first);
85
66
  }
86
67
  /**
87
68
  * Moves the current Node to the last visible child of the current node, and returns the found child. It also moves the current node to this child. If no such child exists, null is returned and the current node is not changed.
@@ -89,15 +70,15 @@ export default class TreeWalker {
89
70
  * @returns Current node.
90
71
  */
91
72
  lastChild() {
92
- const childNodes = this.currentNode ? this.currentNode[PropertySymbol.nodeArray] : [];
93
- if (childNodes.length > 0) {
94
- this.currentNode = childNodes[childNodes.length - 1];
95
- if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
96
- return this.currentNode;
97
- }
98
- return this.previousSibling();
99
- }
100
- return null;
73
+ return this.#traverseChildren(TraverseChildrenTypeEnum.last);
74
+ }
75
+ /**
76
+ * Moves the current Node to its next sibling, if any, and returns the found sibling. If there is no such node, null is returned and the current node is not changed.
77
+ *
78
+ * @returns Current node.
79
+ */
80
+ nextSibling() {
81
+ return this.#traverseSiblings(TraverseSiblingsTypeEnum.next);
101
82
  }
102
83
  /**
103
84
  * Moves the current Node to its previous sibling, if any, and returns the found sibling. If there is no such node, return null and the current node is not changed.
@@ -105,41 +86,78 @@ export default class TreeWalker {
105
86
  * @returns Current node.
106
87
  */
107
88
  previousSibling() {
108
- if (this.currentNode !== this.root &&
109
- this.currentNode &&
110
- this.currentNode[PropertySymbol.parentNode]) {
111
- const siblings = this.currentNode[PropertySymbol.parentNode][PropertySymbol.nodeArray];
112
- const index = siblings.indexOf(this.currentNode);
113
- if (index > 0) {
114
- this.currentNode = siblings[index - 1];
115
- if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
116
- return this.currentNode;
89
+ return this.#traverseSiblings(TraverseSiblingsTypeEnum.previous);
90
+ }
91
+ /**
92
+ * Moves the current Node to the previous visible node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.
93
+ *
94
+ * @returns Current node.
95
+ */
96
+ previousNode() {
97
+ let node = this.currentNode;
98
+ while (node !== this.root) {
99
+ let sibling = node.previousSibling;
100
+ while (sibling !== null) {
101
+ let node = sibling;
102
+ let result = this[PropertySymbol.filterNode](node);
103
+ while (result !== NodeFilter.FILTER_REJECT && node[PropertySymbol.nodeArray].length) {
104
+ node = node.lastChild;
105
+ result = this[PropertySymbol.filterNode](node);
117
106
  }
118
- return this.previousSibling();
107
+ if (result === NodeFilter.FILTER_ACCEPT) {
108
+ this.currentNode = node;
109
+ return node;
110
+ }
111
+ sibling = node.previousSibling;
112
+ }
113
+ if (node === this.root || node.parentNode === null) {
114
+ return null;
115
+ }
116
+ node = node.parentNode;
117
+ if (this[PropertySymbol.filterNode](node) === NodeFilter.FILTER_ACCEPT) {
118
+ this.currentNode = node;
119
+ return node;
119
120
  }
120
121
  }
121
122
  return null;
122
123
  }
123
124
  /**
124
- * Moves the current Node to its next sibling, if any, and returns the found sibling. If there is no such node, null is returned and the current node is not changed.
125
+ * Moves the current Node to the next visible node in the document order.
125
126
  *
126
127
  * @returns Current node.
127
128
  */
128
- nextSibling() {
129
- if (this.currentNode !== this.root &&
130
- this.currentNode &&
131
- this.currentNode[PropertySymbol.parentNode]) {
132
- const siblings = this.currentNode[PropertySymbol.parentNode][PropertySymbol.nodeArray];
133
- const index = siblings.indexOf(this.currentNode);
134
- if (index + 1 < siblings.length) {
135
- this.currentNode = siblings[index + 1];
136
- if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
137
- return this.currentNode;
129
+ nextNode() {
130
+ let node = this.currentNode;
131
+ let result = NodeFilter.FILTER_ACCEPT;
132
+ while (true) {
133
+ while (result !== NodeFilter.FILTER_REJECT && node[PropertySymbol.nodeArray].length) {
134
+ node = node.firstChild;
135
+ result = this[PropertySymbol.filterNode](node);
136
+ if (result === NodeFilter.FILTER_ACCEPT) {
137
+ this.currentNode = node;
138
+ return node;
139
+ }
140
+ }
141
+ while (node !== null) {
142
+ if (node === this.root) {
143
+ return null;
138
144
  }
139
- return this.nextSibling();
145
+ const sibling = node.nextSibling;
146
+ if (sibling !== null) {
147
+ node = sibling;
148
+ break;
149
+ }
150
+ node = node.parentNode;
151
+ }
152
+ if (node === null) {
153
+ return null;
154
+ }
155
+ result = this[PropertySymbol.filterNode](node);
156
+ if (result === NodeFilter.FILTER_ACCEPT) {
157
+ this.currentNode = node;
158
+ return node;
140
159
  }
141
160
  }
142
- return null;
143
161
  }
144
162
  /**
145
163
  * Filters a node.
@@ -163,5 +181,77 @@ export default class TreeWalker {
163
181
  }
164
182
  return NodeFilter.FILTER_ACCEPT;
165
183
  }
184
+ /**
185
+ * Traverses children.
186
+ *
187
+ * @param type Type.
188
+ * @returns Node.
189
+ */
190
+ #traverseChildren(type) {
191
+ let node = this.currentNode;
192
+ node = type === TraverseChildrenTypeEnum.first ? node.firstChild : node.lastChild;
193
+ while (node !== null) {
194
+ const result = this[PropertySymbol.filterNode](node);
195
+ if (result === NodeFilter.FILTER_ACCEPT) {
196
+ this.currentNode = node;
197
+ return node;
198
+ }
199
+ if (result === NodeFilter.FILTER_SKIP) {
200
+ const child = type === TraverseChildrenTypeEnum.first ? node.firstChild : node.lastChild;
201
+ if (child !== null) {
202
+ node = child;
203
+ continue;
204
+ }
205
+ }
206
+ while (node !== null) {
207
+ const sibling = type === TraverseChildrenTypeEnum.first ? node.nextSibling : node.previousSibling;
208
+ if (sibling !== null) {
209
+ node = sibling;
210
+ break;
211
+ }
212
+ const parent = node.parentNode;
213
+ if (parent === null || parent === this.root || parent === this.currentNode) {
214
+ return null;
215
+ }
216
+ node = parent;
217
+ }
218
+ }
219
+ return null;
220
+ }
221
+ /**
222
+ * Traverses siblings.
223
+ *
224
+ * @param type Type.
225
+ * @returns Node.
226
+ */
227
+ #traverseSiblings(type) {
228
+ let node = this.currentNode;
229
+ if (node === this.root) {
230
+ return null;
231
+ }
232
+ while (true) {
233
+ let sibling = type === TraverseSiblingsTypeEnum.next ? node.nextSibling : node.previousSibling;
234
+ while (sibling !== null) {
235
+ const node = sibling;
236
+ const result = this[PropertySymbol.filterNode](node);
237
+ if (result === NodeFilter.FILTER_ACCEPT) {
238
+ this.currentNode = node;
239
+ return node;
240
+ }
241
+ sibling = type === TraverseSiblingsTypeEnum.next ? node.firstChild : node.lastChild;
242
+ if (result === NodeFilter.FILTER_REJECT || sibling === null) {
243
+ sibling =
244
+ type === TraverseSiblingsTypeEnum.next ? node.nextSibling : node.previousSibling;
245
+ }
246
+ }
247
+ node = node.parentNode;
248
+ if (node === null || node === this.root) {
249
+ return null;
250
+ }
251
+ if (this[PropertySymbol.filterNode](node) === NodeFilter.FILTER_ACCEPT) {
252
+ return null;
253
+ }
254
+ }
255
+ }
166
256
  }
167
257
  //# sourceMappingURL=TreeWalker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeWalker.js","sourceRoot":"","sources":["../../src/tree-walker/TreeWalker.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,uBAAuB,CAAC;AACzC,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAEvD,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,YAAY,MAAM,8BAA8B,CAAC;AACxD,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IACvB,IAAI,GAAS,IAAI,CAAC;IAClB,UAAU,GAAG,CAAC,CAAC,CAAC;IAChB,MAAM,GAAgB,IAAI,CAAC;IAC3B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AC,IAAI,CAAC,KAAK,UAAU,CAAC,aAAa,EAAE,CAAC;gBACxE,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-dom",
3
- "version": "17.1.3",
3
+ "version": "17.1.5",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/capricorn86/happy-dom",
6
6
  "repository": "https://github.com/capricorn86/happy-dom",
@@ -25,11 +25,11 @@ export default class DOMStringMap {
25
25
  // Documentation for Proxy:
26
26
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
27
27
  return new Proxy(this, {
28
- get(_target, property: string): string {
28
+ get(_target, property: string): string | void {
29
29
  const attribute = element.getAttribute(
30
30
  'data-' + DOMStringMapUtility.camelCaseToKebab(property)
31
31
  );
32
- if (attribute) {
32
+ if (attribute !== null) {
33
33
  return attribute;
34
34
  }
35
35
  },
@@ -741,7 +741,7 @@ export default class Element
741
741
  *
742
742
  * @param name Name.
743
743
  */
744
- public getAttribute(name: string): string {
744
+ public getAttribute(name: string): string | null {
745
745
  const attribute = this[PropertySymbol.attributes].getNamedItem(name);
746
746
  if (attribute) {
747
747
  return attribute[PropertySymbol.value];