pseudo-dom 0.16.0 → 0.17.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.
@@ -1,527 +1,527 @@
1
- /**
2
- * @file Substitute for the DOM Element Class.
3
- * @author Joshua Heagle <joshuaheagle@gmail.com>
4
- * @version 1.0.0
5
- */
6
- import { PseudoNode } from '../interfaces/PseudoNode';
7
- import { PseudoElement } from '../interfaces/PseudoElement';
8
- import { NodeService } from './NodeService';
9
- import { PseudoNamedNodeMap } from '../interfaces/PseudoNamedNodeMap';
10
- import { PseudoDOMTokenList } from '../interfaces/PseudoDOMTokenList';
11
- import { AttrService } from './AttrService';
12
- import { PseudoHTMLCollection } from '../interfaces/PseudoHTMLCollection';
13
- import { PseudoShadowRoot } from '../interfaces/PseudoShadowRoot';
14
- type attribute = {
15
- name: string;
16
- value: any;
17
- };
18
- type DOMRect = {
19
- x: number;
20
- y: number;
21
- width: number;
22
- height: number;
23
- top: number;
24
- right: number;
25
- bottom: number;
26
- left: number;
27
- };
28
- /**
29
- * Simulate the behaviour of the Element Class when there is no DOM available.
30
- * @author Joshua Heagle <joshuaheagle@gmail.com>
31
- * @class
32
- * @augments PseudoNode
33
- * @property {string} tagName
34
- * @property {string} className
35
- * @property {string} id
36
- * @property {string} innerHtml
37
- * @property {Array} attributes
38
- * @property {function} hasAttribute
39
- * @property {function} setAttribute
40
- * @property {function} getAttribute
41
- * @property {function} removeAttribute
42
- */
43
- export declare class ElementService extends NodeService implements Partial<PseudoElement> {
44
- id: string;
45
- type: string;
46
- clientHeight: number;
47
- clientLeft: number;
48
- clientTop: number;
49
- clientWidth: number;
50
- scrollHeight: number;
51
- scrollLeft: number;
52
- scrollTop: number;
53
- scrollWidth: number;
54
- /** What getBoundingClientRect() returns - not really computed (there is no layout engine), set this directly. */
55
- boundingClientRect: DOMRect;
56
- /** What getClientRects() returns - set this directly. */
57
- clientRects: Array<DOMRect>;
58
- /** What getAnimations() returns - set this directly. */
59
- animations: Array<any>;
60
- /** What checkVisibility() returns - set this directly. */
61
- isVisible: boolean;
62
- private readonly tag;
63
- private readonly attributeList;
64
- private readonly propertyAttributes;
65
- private readonly tokenList;
66
- private readonly capturedPointers;
67
- private shadowRootInstance;
68
- private defaultEventApplied;
69
- /**
70
- * @param {Object} [settings={}]
71
- * @param {string} [settings.tagName=''] The name of the tag this element represents
72
- * @param {Array<{name: string, value: *}>} [settings.attributes=[]] The attributes (also assigned as properties) to start with
73
- * @param {PseudoNode|null} [settings.parent=null] The node to add this element to as its last child
74
- * @param {Array<PseudoNode>} [settings.children=[]] The nodes to start as children
75
- * @constructor
76
- */
77
- constructor({ tagName, attributes, parent, children }?: {
78
- tagName?: string;
79
- attributes?: Array<attribute>;
80
- parent?: PseudoNode | null;
81
- children?: Array<any>;
82
- });
83
- /**
84
- * The attributes with the values they have now: the ones which are also properties (className, id, style, ...) can
85
- * have been changed through the property, which does not change the stored list.
86
- * @returns {Array<{name: string, value: *}>}
87
- */
88
- private currentAttributes;
89
- get nodeName(): string;
90
- /**
91
- * A copy of this element without its children: the same tag and attributes (the values which are objects, such as
92
- * style, are copied too rather than shared), but not its parent or listeners.
93
- * @returns {ElementService}
94
- */
95
- protected cloneShallow(): NodeService;
96
- /**
97
- * Elements are equal when they have the same tag and the same attributes (in any order), which is what isEqualNode
98
- * checks before it compares the children.
99
- * @param {NodeService} other The element to compare with
100
- * @returns {boolean}
101
- */
102
- protected equalsShallow(other: NodeService): boolean;
103
- get tagName(): string;
104
- /**
105
- * The local part of the element's qualified name. There is no real namespace parsing here, so this is always the
106
- * same as tagName.
107
- * @returns {string}
108
- */
109
- get localName(): string;
110
- /**
111
- * The element's namespace prefix, or null when it has none. There is no real namespace parsing here, so this is
112
- * always null.
113
- * @returns {string|null}
114
- */
115
- get prefix(): string | null;
116
- /**
117
- * The HTML markup of this element's children. Only the getter is here (the setter, which needs to build new
118
- * elements from parsed HTML, is on HTMLElementService - see its class comment).
119
- * @returns {string}
120
- */
121
- get innerHTML(): string;
122
- /**
123
- * The HTML markup of this element itself, including its children. Only the getter is here (see innerHTML).
124
- * @returns {string}
125
- */
126
- get outerHTML(): string;
127
- get nodeType(): number;
128
- get attributes(): PseudoNamedNodeMap;
129
- get classList(): PseudoDOMTokenList;
130
- get className(): string;
131
- set className(className: string);
132
- /**
133
- * Some elements have default behaviour, this registers it when the element is added.
134
- * @returns {Function}
135
- */
136
- /**
137
- * A live view of this element's element children (text, comments and the like are not included).
138
- * @returns {PseudoHTMLCollection}
139
- */
140
- get children(): PseudoHTMLCollection;
141
- /**
142
- * How many element children this element has.
143
- * @returns {number}
144
- */
145
- get childElementCount(): number;
146
- /**
147
- * The first child of this element which is an element, or null when there is none.
148
- * @returns {PseudoElement|null}
149
- */
150
- get firstElementChild(): PseudoElement | null;
151
- /**
152
- * The last child of this element which is an element, or null when there is none.
153
- * @returns {PseudoElement|null}
154
- */
155
- get lastElementChild(): PseudoElement | null;
156
- /**
157
- * The sibling after this one which is an element, or null when there is none.
158
- * @returns {PseudoElement|null}
159
- */
160
- get nextElementSibling(): PseudoElement | null;
161
- /**
162
- * The sibling before this one which is an element, or null when there is none.
163
- * @returns {PseudoElement|null}
164
- */
165
- get previousElementSibling(): PseudoElement | null;
166
- /**
167
- * Put an element at a position relative to this one: beforebegin (before this element, as its previous sibling),
168
- * afterbegin (as this element's first child), beforeend (as this element's last child) or afterend (after this
169
- * element, as its next sibling).
170
- * @param {string} position beforebegin, afterbegin, beforeend or afterend
171
- * @param {ElementService} element The element to insert
172
- * @returns {ElementService|null} The inserted element, or null when the position needed a parent this element does not have
173
- * @throws {Error} When the position is not one of the four above
174
- */
175
- insertAdjacentElement(position: string, element: PseudoElement): PseudoElement | null;
176
- /**
177
- * Put text at a position relative to this element, the same as insertAdjacentElement but the text becomes a text node.
178
- * @param {string} position beforebegin, afterbegin, beforeend or afterend
179
- * @param {string} text The text to insert
180
- * @throws {Error} When the position is not one of the four above
181
- */
182
- insertAdjacentText(position: string, text: string): void;
183
- /**
184
- * Shared implementation for insertAdjacentElement / insertAdjacentText.
185
- * @param {string} position beforebegin, afterbegin, beforeend or afterend
186
- * @param {PseudoNode|string} node The node (or text) to insert
187
- * @returns {PseudoNode|null} The inserted node, or null when the position needed a parent this element does not have
188
- * @throws {Error} When the position is not one of the four above
189
- */
190
- private insertAdjacent;
191
- /**
192
- * Not implemented yet (HTML parsing is out of scope for now).
193
- * @param {string} position beforebegin, afterbegin, beforeend or afterend
194
- * @param {string} text The markup which would be parsed
195
- * @throws {Error}
196
- */
197
- insertAdjacentHTML(position: string, text: string): void;
198
- /**
199
- * Whether this element itself (not its descendants) matches the given CSS selector.
200
- * @param {string} selectors A CSS selector
201
- * @returns {boolean}
202
- */
203
- matches(selectors: string): boolean;
204
- /**
205
- * The nearest ancestor of this element (starting with this element itself) which matches the CSS selector, or
206
- * null when none of them do.
207
- * @param {string} selectors A CSS selector
208
- * @returns {PseudoElement|null}
209
- */
210
- closest(selectors: string): PseudoElement | null;
211
- applyDefaultEvent(): Function;
212
- /**
213
- * An element which is added as a child gets its default events (for example a submit button submits its form).
214
- * @param {NodeService} child The node which was inserted
215
- */
216
- protected childInserted(child: NodeService): void;
217
- /**
218
- * Check whether the element has an attribute by that name.
219
- * @param {string} attributeName
220
- * @returns {boolean}
221
- */
222
- hasAttribute(attributeName: string): boolean;
223
- /**
224
- * Set the value of an attribute, adding the attribute if it did not exist.
225
- * @param {string} attributeName
226
- * @param {string} attributeValue
227
- * @returns {undefined}
228
- */
229
- setAttribute(attributeName: string, attributeValue: string): void;
230
- /**
231
- * Retrieve the value of an attribute.
232
- * @param {string} attributeName
233
- * @returns {string|null} The value, or null when there is no such attribute
234
- */
235
- getAttribute(attributeName: string): string | null;
236
- /**
237
- * Remove an attribute from the element.
238
- * @param {string} attributeName
239
- * @returns {undefined}
240
- */
241
- removeAttribute(attributeName: string): void;
242
- /**
243
- * The name of every attribute on the element, in the order they were set.
244
- * @returns {Array<string>}
245
- */
246
- getAttributeNames(): Array<string>;
247
- /**
248
- * Whether the element has any attributes at all.
249
- * @returns {boolean}
250
- */
251
- hasAttributes(): boolean;
252
- /**
253
- * Retrieve the node representation of an attribute.
254
- * @param {string} attributeName
255
- * @returns {AttrService|null} An Attr for the attribute, or null when there is no such attribute
256
- */
257
- getAttributeNode(attributeName: string): AttrService | null;
258
- /**
259
- * Retrieve the node representation of an attribute. There is no real namespace parsing here, so this ignores
260
- * the namespace and behaves exactly like getAttributeNode.
261
- * @param {string} namespace Ignored
262
- * @param {string} attributeName
263
- * @returns {AttrService|null} An Attr for the attribute, or null when there is no such attribute
264
- */
265
- getAttributeNodeNS(namespace: string, attributeName: string): AttrService | null;
266
- /**
267
- * Retrieve the value of an attribute. There is no real namespace parsing here, so this ignores the namespace
268
- * and behaves exactly like getAttribute.
269
- * @param {string} namespace Ignored
270
- * @param {string} attributeName
271
- * @returns {string|null} The value, or null when there is no such attribute
272
- */
273
- getAttributeNS(namespace: string, attributeName: string): string | null;
274
- /**
275
- * Check whether the element has an attribute by that name. There is no real namespace parsing here, so this
276
- * ignores the namespace and behaves exactly like hasAttribute.
277
- * @param {string} namespace Ignored
278
- * @param {string} attributeName
279
- * @returns {boolean}
280
- */
281
- hasAttributeNS(namespace: string, attributeName: string): boolean;
282
- /**
283
- * Remove the node representation of an attribute from the element, and return it.
284
- * @param {AttrService} attr
285
- * @returns {AttrService} The removed Attr
286
- * @throws {Error} When the element has no attribute matching attr.name
287
- */
288
- removeAttributeNode(attr: AttrService): AttrService;
289
- /**
290
- * Remove an attribute from the element. There is no real namespace parsing here, so this ignores the namespace
291
- * and behaves exactly like removeAttribute.
292
- * @param {string} namespace Ignored
293
- * @param {string} attributeName
294
- * @returns {undefined}
295
- */
296
- removeAttributeNS(namespace: string, attributeName: string): void;
297
- /**
298
- * Set the node representation of an attribute, adding the attribute if it did not exist. Returns any previous
299
- * Attr that had the same name, or null when there was none.
300
- * @param {AttrService} attr
301
- * @returns {AttrService|null} The replaced Attr, or null when the attribute was new
302
- */
303
- setAttributeNode(attr: AttrService): AttrService | null;
304
- /**
305
- * Set the node representation of an attribute. There is no real namespace parsing here, so this behaves
306
- * exactly like setAttributeNode (Attr.name already carries any prefix).
307
- * @param {AttrService} attr
308
- * @returns {AttrService|null} The replaced Attr, or null when the attribute was new
309
- */
310
- setAttributeNodeNS(attr: AttrService): AttrService | null;
311
- /**
312
- * Set the value of an attribute, adding the attribute if it did not exist. There is no real namespace parsing
313
- * here, so this ignores the namespace and behaves exactly like setAttribute.
314
- * @param {string} namespace Ignored
315
- * @param {string} attributeName
316
- * @param {string} attributeValue
317
- * @returns {undefined}
318
- */
319
- setAttributeNS(namespace: string, attributeName: string, attributeValue: string): void;
320
- /**
321
- * Add the attribute (with an empty value) when it is not present, or remove it when it is - unless force says
322
- * which of those to do instead. Returns whether the attribute is present after the call.
323
- * @param {string} attributeName
324
- * @param {boolean} [force]
325
- * @returns {boolean}
326
- */
327
- toggleAttribute(attributeName: string, force?: boolean): boolean;
328
- /**
329
- * The size of the element and its position, settable directly - there is no layout engine here to compute it.
330
- * @returns {DOMRect}
331
- */
332
- getBoundingClientRect(): DOMRect;
333
- /**
334
- * The bounding rectangles for each line of text in the element, settable directly - there is no layout engine
335
- * here to compute it.
336
- * @returns {Array<DOMRect>}
337
- */
338
- getClientRects(): Array<DOMRect>;
339
- /**
340
- * The Animation objects currently active on the element, settable directly - there is no animation engine here.
341
- * @returns {Array<*>}
342
- */
343
- getAnimations(): Array<any>;
344
- /**
345
- * Whether the element is expected to be visible, settable directly - there is no rendering here to check it.
346
- * @returns {boolean}
347
- */
348
- checkVisibility(): boolean;
349
- /**
350
- * A read-only view of the element's own inline style declarations (there is no CSS cascade here, so this is not a
351
- * real computed style - just what the element's own style object holds).
352
- * @returns {{get: function(string): (string|undefined)}}
353
- */
354
- computedStyleMap(): {
355
- get: (property: string) => string | undefined;
356
- };
357
- /**
358
- * Whether this element currently has capture of the given pointer.
359
- * @param {number} pointerId
360
- * @returns {boolean}
361
- */
362
- hasPointerCapture(pointerId: number): boolean;
363
- /**
364
- * Give this element capture of the given pointer.
365
- * @param {number} pointerId
366
- * @returns {undefined}
367
- */
368
- setPointerCapture(pointerId: number): void;
369
- /**
370
- * Release this element's capture of the given pointer, if it had it.
371
- * @param {number} pointerId
372
- * @returns {undefined}
373
- */
374
- releasePointerCapture(pointerId: number): void;
375
- /**
376
- * Scroll to the given position (or, given an options object, the position(s) it has). There is no real scrollable
377
- * viewport here: this just sets scrollLeft / scrollTop.
378
- * @param {number|{left: number, top: number}} [x=0]
379
- * @param {number} [y=0]
380
- * @returns {undefined}
381
- */
382
- scroll(x?: number | {
383
- left?: number;
384
- top?: number;
385
- }, y?: number): void;
386
- /**
387
- * Scroll to the given position. An alias for scroll.
388
- * @param {number|{left: number, top: number}} [x=0]
389
- * @param {number} [y=0]
390
- * @returns {undefined}
391
- */
392
- scrollTo(x?: number | {
393
- left?: number;
394
- top?: number;
395
- }, y?: number): void;
396
- /**
397
- * Scroll by the given amount, relative to the current position.
398
- * @param {number|{left: number, top: number}} [x=0]
399
- * @param {number} [y=0]
400
- * @returns {undefined}
401
- */
402
- scrollBy(x?: number | {
403
- left?: number;
404
- top?: number;
405
- }, y?: number): void;
406
- /**
407
- * Scroll an ancestor until this element is in view. There is no real viewport here for that to mean anything, so
408
- * this does nothing (override it on an instance in a test which needs to observe the call).
409
- * @returns {undefined}
410
- */
411
- scrollIntoView(): void;
412
- /**
413
- * Asynchronously ask for the element to be shown fullscreen. There is no real fullscreen here, so this just
414
- * resolves, like a browser granting the request would.
415
- * @returns {Promise<void>}
416
- */
417
- requestFullscreen(): Promise<void>;
418
- /**
419
- * Asynchronously ask for the pointer to be locked to this element. There is no real pointer lock here, so this
420
- * just resolves, like a browser granting the request would.
421
- * @returns {Promise<void>}
422
- */
423
- requestPointerLock(): Promise<void>;
424
- /**
425
- * Attach a shadow tree to this element and return its ShadowRoot. Throws when it already hosts one.
426
- * @param {{mode: string}} options
427
- * @returns {PseudoShadowRoot}
428
- * @throws {Error}
429
- */
430
- attachShadow(options: {
431
- mode: string;
432
- }): PseudoShadowRoot;
433
- /**
434
- * This element's shadow root, when it has one attached in 'open' mode, or null (including when the mode is
435
- * 'closed' - it still exists, but is not reachable this way, like the DOM's).
436
- * @returns {PseudoShadowRoot|null}
437
- */
438
- get shadowRoot(): PseudoShadowRoot | null;
439
- /**
440
- * Read one of the aria-* reflected properties (see the individual aria* getters/setters below).
441
- * @param {string} attributeName A real aria-* attribute name (aria-label, ...)
442
- * @returns {string}
443
- */
444
- private getAriaAttribute;
445
- /**
446
- * Write one of the aria-* reflected properties.
447
- * @param {string} attributeName A real aria-* attribute name (aria-label, ...)
448
- * @param {string} value
449
- * @returns {undefined}
450
- */
451
- private setAriaAttribute;
452
- get ariaAtomic(): string;
453
- set ariaAtomic(value: string);
454
- get ariaAutoComplete(): string;
455
- set ariaAutoComplete(value: string);
456
- get ariaBusy(): string;
457
- set ariaBusy(value: string);
458
- get ariaChecked(): string;
459
- set ariaChecked(value: string);
460
- get ariaColCount(): string;
461
- set ariaColCount(value: string);
462
- get ariaColIndex(): string;
463
- set ariaColIndex(value: string);
464
- get ariaColSpan(): string;
465
- set ariaColSpan(value: string);
466
- get ariaCurrent(): string;
467
- set ariaCurrent(value: string);
468
- get ariaDescription(): string;
469
- set ariaDescription(value: string);
470
- get ariaDisabled(): string;
471
- set ariaDisabled(value: string);
472
- get ariaExpanded(): string;
473
- set ariaExpanded(value: string);
474
- get ariaHasPopup(): string;
475
- set ariaHasPopup(value: string);
476
- get ariaHidden(): string;
477
- set ariaHidden(value: string);
478
- get ariaKeyShortcuts(): string;
479
- set ariaKeyShortcuts(value: string);
480
- get ariaLabel(): string;
481
- set ariaLabel(value: string);
482
- get ariaLevel(): string;
483
- set ariaLevel(value: string);
484
- get ariaLive(): string;
485
- set ariaLive(value: string);
486
- get ariaModal(): string;
487
- set ariaModal(value: string);
488
- get ariaMultiline(): string;
489
- set ariaMultiline(value: string);
490
- get ariaMultiSelectable(): string;
491
- set ariaMultiSelectable(value: string);
492
- get ariaOrientation(): string;
493
- set ariaOrientation(value: string);
494
- get ariaPlaceholder(): string;
495
- set ariaPlaceholder(value: string);
496
- get ariaPosInSet(): string;
497
- set ariaPosInSet(value: string);
498
- get ariaPressed(): string;
499
- set ariaPressed(value: string);
500
- get ariaReadOnly(): string;
501
- set ariaReadOnly(value: string);
502
- get ariaRequired(): string;
503
- set ariaRequired(value: string);
504
- get ariaRoleDescription(): string;
505
- set ariaRoleDescription(value: string);
506
- get ariaRowCount(): string;
507
- set ariaRowCount(value: string);
508
- get ariaRowIndex(): string;
509
- set ariaRowIndex(value: string);
510
- get ariaRowSpan(): string;
511
- set ariaRowSpan(value: string);
512
- get ariaSelected(): string;
513
- set ariaSelected(value: string);
514
- get ariaSetSize(): string;
515
- set ariaSetSize(value: string);
516
- get ariaSort(): string;
517
- set ariaSort(value: string);
518
- get ariaValueMax(): string;
519
- set ariaValueMax(value: string);
520
- get ariaValueMin(): string;
521
- set ariaValueMin(value: string);
522
- get ariaValueNow(): string;
523
- set ariaValueNow(value: string);
524
- get ariaValueText(): string;
525
- set ariaValueText(value: string);
526
- }
527
- export {};
1
+ /**
2
+ * @file Substitute for the DOM Element Class.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ */
6
+ import { PseudoNode } from '../interfaces/PseudoNode';
7
+ import { PseudoElement } from '../interfaces/PseudoElement';
8
+ import { NodeService } from './NodeService';
9
+ import { PseudoNamedNodeMap } from '../interfaces/PseudoNamedNodeMap';
10
+ import { PseudoDOMTokenList } from '../interfaces/PseudoDOMTokenList';
11
+ import { AttrService } from './AttrService';
12
+ import { PseudoHTMLCollection } from '../interfaces/PseudoHTMLCollection';
13
+ import { PseudoShadowRoot } from '../interfaces/PseudoShadowRoot';
14
+ type attribute = {
15
+ name: string;
16
+ value: any;
17
+ };
18
+ type DOMRect = {
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ top: number;
24
+ right: number;
25
+ bottom: number;
26
+ left: number;
27
+ };
28
+ /**
29
+ * Simulate the behaviour of the Element Class when there is no DOM available.
30
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
31
+ * @class
32
+ * @augments PseudoNode
33
+ * @property {string} tagName
34
+ * @property {string} className
35
+ * @property {string} id
36
+ * @property {string} innerHtml
37
+ * @property {Array} attributes
38
+ * @property {function} hasAttribute
39
+ * @property {function} setAttribute
40
+ * @property {function} getAttribute
41
+ * @property {function} removeAttribute
42
+ */
43
+ export declare class ElementService extends NodeService implements Partial<PseudoElement> {
44
+ id: string;
45
+ type: string;
46
+ clientHeight: number;
47
+ clientLeft: number;
48
+ clientTop: number;
49
+ clientWidth: number;
50
+ scrollHeight: number;
51
+ scrollLeft: number;
52
+ scrollTop: number;
53
+ scrollWidth: number;
54
+ /** What getBoundingClientRect() returns - not really computed (there is no layout engine), set this directly. */
55
+ boundingClientRect: DOMRect;
56
+ /** What getClientRects() returns - set this directly. */
57
+ clientRects: Array<DOMRect>;
58
+ /** What getAnimations() returns - set this directly. */
59
+ animations: Array<any>;
60
+ /** What checkVisibility() returns - set this directly. */
61
+ isVisible: boolean;
62
+ private readonly tag;
63
+ private readonly attributeList;
64
+ private readonly propertyAttributes;
65
+ private readonly tokenList;
66
+ private readonly capturedPointers;
67
+ private shadowRootInstance;
68
+ private defaultEventApplied;
69
+ /**
70
+ * @param {Object} [settings={}]
71
+ * @param {string} [settings.tagName=''] The name of the tag this element represents
72
+ * @param {Array<{name: string, value: *}>} [settings.attributes=[]] The attributes (also assigned as properties) to start with
73
+ * @param {PseudoNode|null} [settings.parent=null] The node to add this element to as its last child
74
+ * @param {Array<PseudoNode>} [settings.children=[]] The nodes to start as children
75
+ * @constructor
76
+ */
77
+ constructor({ tagName, attributes, parent, children }?: {
78
+ tagName?: string;
79
+ attributes?: Array<attribute>;
80
+ parent?: PseudoNode | null;
81
+ children?: Array<any>;
82
+ });
83
+ /**
84
+ * The attributes with the values they have now: the ones which are also properties (className, id, style, ...) can
85
+ * have been changed through the property, which does not change the stored list.
86
+ * @returns {Array<{name: string, value: *}>}
87
+ */
88
+ private currentAttributes;
89
+ get nodeName(): string;
90
+ /**
91
+ * A copy of this element without its children: the same tag and attributes (the values which are objects, such as
92
+ * style, are copied too rather than shared), but not its parent or listeners.
93
+ * @returns {ElementService}
94
+ */
95
+ protected cloneShallow(): NodeService;
96
+ /**
97
+ * Elements are equal when they have the same tag and the same attributes (in any order), which is what isEqualNode
98
+ * checks before it compares the children.
99
+ * @param {NodeService} other The element to compare with
100
+ * @returns {boolean}
101
+ */
102
+ protected equalsShallow(other: NodeService): boolean;
103
+ get tagName(): string;
104
+ /**
105
+ * The local part of the element's qualified name. There is no real namespace parsing here, so this is always the
106
+ * same as tagName.
107
+ * @returns {string}
108
+ */
109
+ get localName(): string;
110
+ /**
111
+ * The element's namespace prefix, or null when it has none. There is no real namespace parsing here, so this is
112
+ * always null.
113
+ * @returns {string|null}
114
+ */
115
+ get prefix(): string | null;
116
+ /**
117
+ * The HTML markup of this element's children. Only the getter is here (the setter, which needs to build new
118
+ * elements from parsed HTML, is on HTMLElementService - see its class comment).
119
+ * @returns {string}
120
+ */
121
+ get innerHTML(): string;
122
+ /**
123
+ * The HTML markup of this element itself, including its children. Only the getter is here (see innerHTML).
124
+ * @returns {string}
125
+ */
126
+ get outerHTML(): string;
127
+ get nodeType(): number;
128
+ get attributes(): PseudoNamedNodeMap;
129
+ get classList(): PseudoDOMTokenList;
130
+ get className(): string;
131
+ set className(className: string);
132
+ /**
133
+ * Some elements have default behaviour, this registers it when the element is added.
134
+ * @returns {Function}
135
+ */
136
+ /**
137
+ * A live view of this element's element children (text, comments and the like are not included).
138
+ * @returns {PseudoHTMLCollection}
139
+ */
140
+ get children(): PseudoHTMLCollection;
141
+ /**
142
+ * How many element children this element has.
143
+ * @returns {number}
144
+ */
145
+ get childElementCount(): number;
146
+ /**
147
+ * The first child of this element which is an element, or null when there is none.
148
+ * @returns {PseudoElement|null}
149
+ */
150
+ get firstElementChild(): PseudoElement | null;
151
+ /**
152
+ * The last child of this element which is an element, or null when there is none.
153
+ * @returns {PseudoElement|null}
154
+ */
155
+ get lastElementChild(): PseudoElement | null;
156
+ /**
157
+ * The sibling after this one which is an element, or null when there is none.
158
+ * @returns {PseudoElement|null}
159
+ */
160
+ get nextElementSibling(): PseudoElement | null;
161
+ /**
162
+ * The sibling before this one which is an element, or null when there is none.
163
+ * @returns {PseudoElement|null}
164
+ */
165
+ get previousElementSibling(): PseudoElement | null;
166
+ /**
167
+ * Put an element at a position relative to this one: beforebegin (before this element, as its previous sibling),
168
+ * afterbegin (as this element's first child), beforeend (as this element's last child) or afterend (after this
169
+ * element, as its next sibling).
170
+ * @param {string} position beforebegin, afterbegin, beforeend or afterend
171
+ * @param {ElementService} element The element to insert
172
+ * @returns {ElementService|null} The inserted element, or null when the position needed a parent this element does not have
173
+ * @throws {Error} When the position is not one of the four above
174
+ */
175
+ insertAdjacentElement(position: string, element: PseudoElement): PseudoElement | null;
176
+ /**
177
+ * Put text at a position relative to this element, the same as insertAdjacentElement but the text becomes a text node.
178
+ * @param {string} position beforebegin, afterbegin, beforeend or afterend
179
+ * @param {string} text The text to insert
180
+ * @throws {Error} When the position is not one of the four above
181
+ */
182
+ insertAdjacentText(position: string, text: string): void;
183
+ /**
184
+ * Shared implementation for insertAdjacentElement / insertAdjacentText.
185
+ * @param {string} position beforebegin, afterbegin, beforeend or afterend
186
+ * @param {PseudoNode|string} node The node (or text) to insert
187
+ * @returns {PseudoNode|null} The inserted node, or null when the position needed a parent this element does not have
188
+ * @throws {Error} When the position is not one of the four above
189
+ */
190
+ private insertAdjacent;
191
+ /**
192
+ * Not implemented yet (HTML parsing is out of scope for now).
193
+ * @param {string} position beforebegin, afterbegin, beforeend or afterend
194
+ * @param {string} text The markup which would be parsed
195
+ * @throws {Error}
196
+ */
197
+ insertAdjacentHTML(position: string, text: string): void;
198
+ /**
199
+ * Whether this element itself (not its descendants) matches the given CSS selector.
200
+ * @param {string} selectors A CSS selector
201
+ * @returns {boolean}
202
+ */
203
+ matches(selectors: string): boolean;
204
+ /**
205
+ * The nearest ancestor of this element (starting with this element itself) which matches the CSS selector, or
206
+ * null when none of them do.
207
+ * @param {string} selectors A CSS selector
208
+ * @returns {PseudoElement|null}
209
+ */
210
+ closest(selectors: string): PseudoElement | null;
211
+ applyDefaultEvent(): Function;
212
+ /**
213
+ * An element which is added as a child gets its default events (for example a submit button submits its form).
214
+ * @param {NodeService} child The node which was inserted
215
+ */
216
+ protected childInserted(child: NodeService): void;
217
+ /**
218
+ * Check whether the element has an attribute by that name.
219
+ * @param {string} attributeName
220
+ * @returns {boolean}
221
+ */
222
+ hasAttribute(attributeName: string): boolean;
223
+ /**
224
+ * Set the value of an attribute, adding the attribute if it did not exist.
225
+ * @param {string} attributeName
226
+ * @param {string} attributeValue
227
+ * @returns {undefined}
228
+ */
229
+ setAttribute(attributeName: string, attributeValue: string): void;
230
+ /**
231
+ * Retrieve the value of an attribute.
232
+ * @param {string} attributeName
233
+ * @returns {string|null} The value, or null when there is no such attribute
234
+ */
235
+ getAttribute(attributeName: string): string | null;
236
+ /**
237
+ * Remove an attribute from the element.
238
+ * @param {string} attributeName
239
+ * @returns {undefined}
240
+ */
241
+ removeAttribute(attributeName: string): void;
242
+ /**
243
+ * The name of every attribute on the element, in the order they were set.
244
+ * @returns {Array<string>}
245
+ */
246
+ getAttributeNames(): Array<string>;
247
+ /**
248
+ * Whether the element has any attributes at all.
249
+ * @returns {boolean}
250
+ */
251
+ hasAttributes(): boolean;
252
+ /**
253
+ * Retrieve the node representation of an attribute.
254
+ * @param {string} attributeName
255
+ * @returns {AttrService|null} An Attr for the attribute, or null when there is no such attribute
256
+ */
257
+ getAttributeNode(attributeName: string): AttrService | null;
258
+ /**
259
+ * Retrieve the node representation of an attribute. There is no real namespace parsing here, so this ignores
260
+ * the namespace and behaves exactly like getAttributeNode.
261
+ * @param {string} namespace Ignored
262
+ * @param {string} attributeName
263
+ * @returns {AttrService|null} An Attr for the attribute, or null when there is no such attribute
264
+ */
265
+ getAttributeNodeNS(namespace: string, attributeName: string): AttrService | null;
266
+ /**
267
+ * Retrieve the value of an attribute. There is no real namespace parsing here, so this ignores the namespace
268
+ * and behaves exactly like getAttribute.
269
+ * @param {string} namespace Ignored
270
+ * @param {string} attributeName
271
+ * @returns {string|null} The value, or null when there is no such attribute
272
+ */
273
+ getAttributeNS(namespace: string, attributeName: string): string | null;
274
+ /**
275
+ * Check whether the element has an attribute by that name. There is no real namespace parsing here, so this
276
+ * ignores the namespace and behaves exactly like hasAttribute.
277
+ * @param {string} namespace Ignored
278
+ * @param {string} attributeName
279
+ * @returns {boolean}
280
+ */
281
+ hasAttributeNS(namespace: string, attributeName: string): boolean;
282
+ /**
283
+ * Remove the node representation of an attribute from the element, and return it.
284
+ * @param {AttrService} attr
285
+ * @returns {AttrService} The removed Attr
286
+ * @throws {Error} When the element has no attribute matching attr.name
287
+ */
288
+ removeAttributeNode(attr: AttrService): AttrService;
289
+ /**
290
+ * Remove an attribute from the element. There is no real namespace parsing here, so this ignores the namespace
291
+ * and behaves exactly like removeAttribute.
292
+ * @param {string} namespace Ignored
293
+ * @param {string} attributeName
294
+ * @returns {undefined}
295
+ */
296
+ removeAttributeNS(namespace: string, attributeName: string): void;
297
+ /**
298
+ * Set the node representation of an attribute, adding the attribute if it did not exist. Returns any previous
299
+ * Attr that had the same name, or null when there was none.
300
+ * @param {AttrService} attr
301
+ * @returns {AttrService|null} The replaced Attr, or null when the attribute was new
302
+ */
303
+ setAttributeNode(attr: AttrService): AttrService | null;
304
+ /**
305
+ * Set the node representation of an attribute. There is no real namespace parsing here, so this behaves
306
+ * exactly like setAttributeNode (Attr.name already carries any prefix).
307
+ * @param {AttrService} attr
308
+ * @returns {AttrService|null} The replaced Attr, or null when the attribute was new
309
+ */
310
+ setAttributeNodeNS(attr: AttrService): AttrService | null;
311
+ /**
312
+ * Set the value of an attribute, adding the attribute if it did not exist. There is no real namespace parsing
313
+ * here, so this ignores the namespace and behaves exactly like setAttribute.
314
+ * @param {string} namespace Ignored
315
+ * @param {string} attributeName
316
+ * @param {string} attributeValue
317
+ * @returns {undefined}
318
+ */
319
+ setAttributeNS(namespace: string, attributeName: string, attributeValue: string): void;
320
+ /**
321
+ * Add the attribute (with an empty value) when it is not present, or remove it when it is - unless force says
322
+ * which of those to do instead. Returns whether the attribute is present after the call.
323
+ * @param {string} attributeName
324
+ * @param {boolean} [force]
325
+ * @returns {boolean}
326
+ */
327
+ toggleAttribute(attributeName: string, force?: boolean): boolean;
328
+ /**
329
+ * The size of the element and its position, settable directly - there is no layout engine here to compute it.
330
+ * @returns {DOMRect}
331
+ */
332
+ getBoundingClientRect(): DOMRect;
333
+ /**
334
+ * The bounding rectangles for each line of text in the element, settable directly - there is no layout engine
335
+ * here to compute it.
336
+ * @returns {Array<DOMRect>}
337
+ */
338
+ getClientRects(): Array<DOMRect>;
339
+ /**
340
+ * The Animation objects currently active on the element, settable directly - there is no animation engine here.
341
+ * @returns {Array<*>}
342
+ */
343
+ getAnimations(): Array<any>;
344
+ /**
345
+ * Whether the element is expected to be visible, settable directly - there is no rendering here to check it.
346
+ * @returns {boolean}
347
+ */
348
+ checkVisibility(): boolean;
349
+ /**
350
+ * A read-only view of the element's own inline style declarations (there is no CSS cascade here, so this is not a
351
+ * real computed style - just what the element's own style object holds).
352
+ * @returns {{get: function(string): (string|undefined)}}
353
+ */
354
+ computedStyleMap(): {
355
+ get: (property: string) => string | undefined;
356
+ };
357
+ /**
358
+ * Whether this element currently has capture of the given pointer.
359
+ * @param {number} pointerId
360
+ * @returns {boolean}
361
+ */
362
+ hasPointerCapture(pointerId: number): boolean;
363
+ /**
364
+ * Give this element capture of the given pointer.
365
+ * @param {number} pointerId
366
+ * @returns {undefined}
367
+ */
368
+ setPointerCapture(pointerId: number): void;
369
+ /**
370
+ * Release this element's capture of the given pointer, if it had it.
371
+ * @param {number} pointerId
372
+ * @returns {undefined}
373
+ */
374
+ releasePointerCapture(pointerId: number): void;
375
+ /**
376
+ * Scroll to the given position (or, given an options object, the position(s) it has). There is no real scrollable
377
+ * viewport here: this just sets scrollLeft / scrollTop.
378
+ * @param {number|{left: number, top: number}} [x=0]
379
+ * @param {number} [y=0]
380
+ * @returns {undefined}
381
+ */
382
+ scroll(x?: number | {
383
+ left?: number;
384
+ top?: number;
385
+ }, y?: number): void;
386
+ /**
387
+ * Scroll to the given position. An alias for scroll.
388
+ * @param {number|{left: number, top: number}} [x=0]
389
+ * @param {number} [y=0]
390
+ * @returns {undefined}
391
+ */
392
+ scrollTo(x?: number | {
393
+ left?: number;
394
+ top?: number;
395
+ }, y?: number): void;
396
+ /**
397
+ * Scroll by the given amount, relative to the current position.
398
+ * @param {number|{left: number, top: number}} [x=0]
399
+ * @param {number} [y=0]
400
+ * @returns {undefined}
401
+ */
402
+ scrollBy(x?: number | {
403
+ left?: number;
404
+ top?: number;
405
+ }, y?: number): void;
406
+ /**
407
+ * Scroll an ancestor until this element is in view. There is no real viewport here for that to mean anything, so
408
+ * this does nothing (override it on an instance in a test which needs to observe the call).
409
+ * @returns {undefined}
410
+ */
411
+ scrollIntoView(): void;
412
+ /**
413
+ * Asynchronously ask for the element to be shown fullscreen. There is no real fullscreen here, so this just
414
+ * resolves, like a browser granting the request would.
415
+ * @returns {Promise<void>}
416
+ */
417
+ requestFullscreen(): Promise<void>;
418
+ /**
419
+ * Asynchronously ask for the pointer to be locked to this element. There is no real pointer lock here, so this
420
+ * just resolves, like a browser granting the request would.
421
+ * @returns {Promise<void>}
422
+ */
423
+ requestPointerLock(): Promise<void>;
424
+ /**
425
+ * Attach a shadow tree to this element and return its ShadowRoot. Throws when it already hosts one.
426
+ * @param {{mode: string}} options
427
+ * @returns {PseudoShadowRoot}
428
+ * @throws {Error}
429
+ */
430
+ attachShadow(options: {
431
+ mode: string;
432
+ }): PseudoShadowRoot;
433
+ /**
434
+ * This element's shadow root, when it has one attached in 'open' mode, or null (including when the mode is
435
+ * 'closed' - it still exists, but is not reachable this way, like the DOM's).
436
+ * @returns {PseudoShadowRoot|null}
437
+ */
438
+ get shadowRoot(): PseudoShadowRoot | null;
439
+ /**
440
+ * Read one of the aria-* reflected properties (see the individual aria* getters/setters below).
441
+ * @param {string} attributeName A real aria-* attribute name (aria-label, ...)
442
+ * @returns {string}
443
+ */
444
+ private getAriaAttribute;
445
+ /**
446
+ * Write one of the aria-* reflected properties.
447
+ * @param {string} attributeName A real aria-* attribute name (aria-label, ...)
448
+ * @param {string} value
449
+ * @returns {undefined}
450
+ */
451
+ private setAriaAttribute;
452
+ get ariaAtomic(): string;
453
+ set ariaAtomic(value: string);
454
+ get ariaAutoComplete(): string;
455
+ set ariaAutoComplete(value: string);
456
+ get ariaBusy(): string;
457
+ set ariaBusy(value: string);
458
+ get ariaChecked(): string;
459
+ set ariaChecked(value: string);
460
+ get ariaColCount(): string;
461
+ set ariaColCount(value: string);
462
+ get ariaColIndex(): string;
463
+ set ariaColIndex(value: string);
464
+ get ariaColSpan(): string;
465
+ set ariaColSpan(value: string);
466
+ get ariaCurrent(): string;
467
+ set ariaCurrent(value: string);
468
+ get ariaDescription(): string;
469
+ set ariaDescription(value: string);
470
+ get ariaDisabled(): string;
471
+ set ariaDisabled(value: string);
472
+ get ariaExpanded(): string;
473
+ set ariaExpanded(value: string);
474
+ get ariaHasPopup(): string;
475
+ set ariaHasPopup(value: string);
476
+ get ariaHidden(): string;
477
+ set ariaHidden(value: string);
478
+ get ariaKeyShortcuts(): string;
479
+ set ariaKeyShortcuts(value: string);
480
+ get ariaLabel(): string;
481
+ set ariaLabel(value: string);
482
+ get ariaLevel(): string;
483
+ set ariaLevel(value: string);
484
+ get ariaLive(): string;
485
+ set ariaLive(value: string);
486
+ get ariaModal(): string;
487
+ set ariaModal(value: string);
488
+ get ariaMultiline(): string;
489
+ set ariaMultiline(value: string);
490
+ get ariaMultiSelectable(): string;
491
+ set ariaMultiSelectable(value: string);
492
+ get ariaOrientation(): string;
493
+ set ariaOrientation(value: string);
494
+ get ariaPlaceholder(): string;
495
+ set ariaPlaceholder(value: string);
496
+ get ariaPosInSet(): string;
497
+ set ariaPosInSet(value: string);
498
+ get ariaPressed(): string;
499
+ set ariaPressed(value: string);
500
+ get ariaReadOnly(): string;
501
+ set ariaReadOnly(value: string);
502
+ get ariaRequired(): string;
503
+ set ariaRequired(value: string);
504
+ get ariaRoleDescription(): string;
505
+ set ariaRoleDescription(value: string);
506
+ get ariaRowCount(): string;
507
+ set ariaRowCount(value: string);
508
+ get ariaRowIndex(): string;
509
+ set ariaRowIndex(value: string);
510
+ get ariaRowSpan(): string;
511
+ set ariaRowSpan(value: string);
512
+ get ariaSelected(): string;
513
+ set ariaSelected(value: string);
514
+ get ariaSetSize(): string;
515
+ set ariaSetSize(value: string);
516
+ get ariaSort(): string;
517
+ set ariaSort(value: string);
518
+ get ariaValueMax(): string;
519
+ set ariaValueMax(value: string);
520
+ get ariaValueMin(): string;
521
+ set ariaValueMin(value: string);
522
+ get ariaValueNow(): string;
523
+ set ariaValueNow(value: string);
524
+ get ariaValueText(): string;
525
+ set ariaValueText(value: string);
526
+ }
527
+ export {};