pseudo-dom 0.7.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.
- package/README.md +262 -236
- package/browser/pseudo-dom.js +628 -548
- package/browser/pseudo-dom.min.js +1 -1
- package/dist/classes/PseudoHTMLDocument.d.ts +41 -67
- package/dist/classes/PseudoHTMLDocument.js +74 -144
- package/dist/classes/PseudoHTMLDocument.min.js +1 -1
- package/dist/factories/cssSelectAdapter.d.ts +23 -23
- package/dist/factories/cssSelectAdapter.js +87 -87
- package/dist/factories/query.d.ts +33 -33
- package/dist/factories/query.js +66 -66
- package/dist/functions/getElementById.d.ts +13 -0
- package/dist/functions/getElementById.js +33 -0
- package/dist/functions/getElementById.min.js +1 -0
- package/dist/interfaces/PseudoDocument.d.ts +25 -0
- package/dist/interfaces/PseudoDocumentFragment.d.ts +10 -3
- package/dist/interfaces/PseudoElement.d.ts +702 -702
- package/dist/services/DocumentFragmentService.d.ts +21 -13
- package/dist/services/DocumentFragmentService.js +42 -24
- package/dist/services/DocumentFragmentService.min.js +1 -1
- package/dist/services/DocumentService.d.ts +28 -1
- package/dist/services/DocumentService.js +64 -15
- package/dist/services/DocumentService.min.js +1 -1
- package/dist/services/ElementService.d.ts +191 -191
- package/dist/services/ElementService.js +426 -426
- package/dist/services/HTMLCollectionService.d.ts +54 -54
- package/dist/services/HTMLCollectionService.js +92 -92
- package/dist/services/NodeService.d.ts +297 -297
- package/dist/services/NodeService.js +721 -721
- package/package.json +2 -2
- package/dist/classes.d.ts +0 -20
- package/dist/classes.js +0 -31
- package/dist/classes.min.js +0 -1
- package/dist/factories/generateNode.d.ts +0 -32
- package/dist/factories/generateNode.js +0 -85
- package/dist/factories/generateNode.min.js +0 -1
- package/dist/factories.d.ts +0 -11
- package/dist/factories.js +0 -27
- package/dist/factories.min.js +0 -1
- package/dist/functions.d.ts +0 -5
- package/dist/functions.js +0 -23
- package/dist/functions.min.js +0 -1
|
@@ -1,297 +1,297 @@
|
|
|
1
|
-
import { PseudoNodeList } from '../classes/PseudoNodeList';
|
|
2
|
-
import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
|
|
3
|
-
import { TreeLinker } from 'collect-your-stuff/dist/collections/linked-tree-list/TreeLinker';
|
|
4
|
-
import { PseudoNode } from '../interfaces/PseudoNode';
|
|
5
|
-
import EventTargetService from './EventTargetService';
|
|
6
|
-
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
7
|
-
import { PseudoDocument } from '../interfaces/PseudoDocument';
|
|
8
|
-
import { PseudoDocumentFragment } from '../interfaces/PseudoDocumentFragment';
|
|
9
|
-
import { HTMLCollectionService } from './HTMLCollectionService';
|
|
10
|
-
/**
|
|
11
|
-
* Simulate the behaviour of the Node Class when there is no DOM available.
|
|
12
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
13
|
-
* @class
|
|
14
|
-
* @augments PseudoEventTarget
|
|
15
|
-
* @property {string} name
|
|
16
|
-
* @property {function} appendChild
|
|
17
|
-
* @property {function} removeChild
|
|
18
|
-
*/
|
|
19
|
-
export declare class NodeService extends EventTargetService implements PseudoNode {
|
|
20
|
-
static readonly DEFAULT_NODE = 0;
|
|
21
|
-
static readonly ELEMENT_NODE = 1;
|
|
22
|
-
static readonly ATTRIBUTE_NODE = 2;
|
|
23
|
-
static readonly TEXT_NODE = 3;
|
|
24
|
-
static readonly CDATA_SECTION_NODE = 4;
|
|
25
|
-
static readonly ENTITY_REFERENCE_NODE = 5;
|
|
26
|
-
static readonly ENTITY_NODE = 6;
|
|
27
|
-
static readonly PROCESSING_INSTRUCTION_NODE = 7;
|
|
28
|
-
static readonly COMMENT_NODE = 8;
|
|
29
|
-
static readonly DOCUMENT_NODE = 9;
|
|
30
|
-
static readonly DOCUMENT_TYPE_NODE = 10;
|
|
31
|
-
static readonly DOCUMENT_FRAGMENT_NODE = 11;
|
|
32
|
-
static readonly NOTATION_NODE = 12;
|
|
33
|
-
static readonly DOCUMENT_POSITION_DISCONNECTED = 1;
|
|
34
|
-
static readonly DOCUMENT_POSITION_PRECEDING = 2;
|
|
35
|
-
static readonly DOCUMENT_POSITION_FOLLOWING = 4;
|
|
36
|
-
static readonly DOCUMENT_POSITION_CONTAINS = 8;
|
|
37
|
-
static readonly DOCUMENT_POSITION_CONTAINED_BY = 16;
|
|
38
|
-
static readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
|
|
39
|
-
private static nextNodeId;
|
|
40
|
-
/** The raw list of every child node (all types), used to implement childNodes/firstChild/lastChild/insertBefore/removeChild. Not the same thing as Element.children (an HTMLCollection of just the element children). */
|
|
41
|
-
protected childList: PseudoNodeList | LinkedTreeList;
|
|
42
|
-
parent: PseudoNode | null;
|
|
43
|
-
protected nodeNameValue: string;
|
|
44
|
-
private nodeValueStore;
|
|
45
|
-
/** The document which made this node (createElement and the like), for when it is not in a tree yet. */
|
|
46
|
-
protected ownerDocumentStore: PseudoDocument | null;
|
|
47
|
-
/** A number for each node in the order they were made, used to give nodes which are in different trees a consistent order. */
|
|
48
|
-
private readonly nodeId;
|
|
49
|
-
/** The linker which holds this node in the children list of its parent, from which its siblings are found (null while it has no parent). */
|
|
50
|
-
protected listLinker: TreeLinker | null;
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* @constructor
|
|
54
|
-
*/
|
|
55
|
-
constructor();
|
|
56
|
-
get baseURI(): Location | string;
|
|
57
|
-
get childNodes(): PseudoNodeList | LinkedTreeList;
|
|
58
|
-
get firstChild(): PseudoNode | null;
|
|
59
|
-
get isConnected(): boolean;
|
|
60
|
-
get lastChild(): PseudoNode | null;
|
|
61
|
-
get nextSibling(): PseudoNode | null;
|
|
62
|
-
get nodeName(): string;
|
|
63
|
-
get nodeType(): number;
|
|
64
|
-
get nodeValue(): string | null;
|
|
65
|
-
set nodeValue(value: string | null);
|
|
66
|
-
get ownerDocument(): PseudoDocument | null;
|
|
67
|
-
get parentNode(): PseudoNode | null;
|
|
68
|
-
get parentElement(): PseudoElement | null;
|
|
69
|
-
get previousSibling(): PseudoNode | null;
|
|
70
|
-
get textContent(): string | null;
|
|
71
|
-
set textContent(text: string | null);
|
|
72
|
-
/**
|
|
73
|
-
* Add a node as the last child of this node (a node which is already in a tree is moved).
|
|
74
|
-
* @param {PseudoNode} childNode The node to add
|
|
75
|
-
* @returns {PseudoNode} The added node
|
|
76
|
-
*/
|
|
77
|
-
appendChild(childNode: PseudoNode): PseudoNode;
|
|
78
|
-
/**
|
|
79
|
-
* Whether this kind of node can have children (text, comments and attributes cannot).
|
|
80
|
-
* @returns {boolean}
|
|
81
|
-
*/
|
|
82
|
-
protected get acceptsChildren(): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Make a copy of this node without its children, its parent or its listeners, which is what cloneNode starts from.
|
|
85
|
-
* Kinds of node which are made with arguments override this to give them.
|
|
86
|
-
* @returns {NodeService}
|
|
87
|
-
*/
|
|
88
|
-
protected cloneShallow(): NodeService;
|
|
89
|
-
/**
|
|
90
|
-
* Whether another node of the same type is equal to this one apart from its children, which isEqualNode compares
|
|
91
|
-
* afterwards. Kinds of node with more to compare (an element has attributes) override this.
|
|
92
|
-
* @param {NodeService} other The node to compare with
|
|
93
|
-
* @returns {boolean}
|
|
94
|
-
*/
|
|
95
|
-
protected equalsShallow(other: NodeService): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Add nodes (strings become text nodes) as the last children of this node, in the order given.
|
|
98
|
-
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
99
|
-
* @throws {Error} When this kind of node cannot have children
|
|
100
|
-
*/
|
|
101
|
-
append(...nodes: Array<PseudoNode | string>): void;
|
|
102
|
-
/**
|
|
103
|
-
* Add nodes (strings become text nodes) as the first children of this node, in the order given.
|
|
104
|
-
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
105
|
-
* @throws {Error} When this kind of node cannot have children
|
|
106
|
-
*/
|
|
107
|
-
prepend(...nodes: Array<PseudoNode | string>): void;
|
|
108
|
-
/**
|
|
109
|
-
* Remove every child of this node and put the given nodes (strings become text nodes) in their place, in order.
|
|
110
|
-
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
111
|
-
* @throws {Error} When this kind of node cannot have children
|
|
112
|
-
*/
|
|
113
|
-
replaceChildren(...nodes: Array<PseudoNode | string>): void;
|
|
114
|
-
/**
|
|
115
|
-
* Add nodes (strings become text nodes) as this node's previous siblings, in order. Does nothing when this node has
|
|
116
|
-
* no parent.
|
|
117
|
-
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
118
|
-
*/
|
|
119
|
-
before(...nodes: Array<PseudoNode | string>): void;
|
|
120
|
-
/**
|
|
121
|
-
* Add nodes (strings become text nodes) as this node's next siblings, in order. Does nothing when this node has no
|
|
122
|
-
* parent.
|
|
123
|
-
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
124
|
-
*/
|
|
125
|
-
after(...nodes: Array<PseudoNode | string>): void;
|
|
126
|
-
/**
|
|
127
|
-
* Put the given nodes (strings become text nodes) where this node is, in order, then remove this node. Does nothing
|
|
128
|
-
* when this node has no parent.
|
|
129
|
-
* @param {...(PseudoNode|string)} nodes The nodes (or text) to put in this node's place
|
|
130
|
-
*/
|
|
131
|
-
replaceWith(...nodes: Array<PseudoNode | string>): void;
|
|
132
|
-
/**
|
|
133
|
-
* Remove this node from its parent. Does nothing when it has no parent.
|
|
134
|
-
*/
|
|
135
|
-
remove(): void;
|
|
136
|
-
/**
|
|
137
|
-
* Turn a value given to append / prepend / before / after / replaceWith / replaceChildren into a node: a string
|
|
138
|
-
* becomes a text node belonging to this node's document, anything else is returned as it is.
|
|
139
|
-
* @param {PseudoNode|string} value The value to add
|
|
140
|
-
* @returns {PseudoNode}
|
|
141
|
-
*/
|
|
142
|
-
private toChildNode;
|
|
143
|
-
/**
|
|
144
|
-
* Every element below this node with the given tag name (or every element when tagName is *), live.
|
|
145
|
-
* @param {string} tagName
|
|
146
|
-
* @returns {PseudoHTMLCollection}
|
|
147
|
-
*/
|
|
148
|
-
getElementsByTagName(tagName: string): HTMLCollectionService;
|
|
149
|
-
/**
|
|
150
|
-
* Every element below this node which has all of the given (space separated) classes, live.
|
|
151
|
-
* @param {string} className
|
|
152
|
-
* @returns {PseudoHTMLCollection}
|
|
153
|
-
*/
|
|
154
|
-
getElementsByClassName(className: string): HTMLCollectionService;
|
|
155
|
-
/**
|
|
156
|
-
* The first element below this node which matches the CSS selector, in tree order, or null when there is none.
|
|
157
|
-
* @param {string} selectors A CSS selector
|
|
158
|
-
* @returns {PseudoElement|null}
|
|
159
|
-
*/
|
|
160
|
-
querySelector(selectors: string): PseudoElement | null;
|
|
161
|
-
/**
|
|
162
|
-
* Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
|
|
163
|
-
* collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
|
|
164
|
-
* @param {string} selectors A CSS selector
|
|
165
|
-
* @returns {Array<PseudoElement>}
|
|
166
|
-
*/
|
|
167
|
-
querySelectorAll(selectors: string): Array<PseudoElement>;
|
|
168
|
-
/**
|
|
169
|
-
* Called each time a node has been inserted as a child of this node, so that nodes which need to react to children
|
|
170
|
-
* (for example elements applying default events) can do so.
|
|
171
|
-
* @param {NodeService} child The node which was inserted
|
|
172
|
-
*/
|
|
173
|
-
protected childInserted(child: NodeService): void;
|
|
174
|
-
/**
|
|
175
|
-
* Make a copy of this node (without its parent, and without its event listeners). With deep the children are copied
|
|
176
|
-
* too, all the way down.
|
|
177
|
-
* @param {boolean} [deep=false] Copy the children as well
|
|
178
|
-
* @returns {PseudoNode}
|
|
179
|
-
*/
|
|
180
|
-
cloneNode(deep?: boolean): PseudoNode;
|
|
181
|
-
/**
|
|
182
|
-
* Say where another node is in relation to this one, as the bits of NodeService.DOCUMENT_POSITION_*: 0 for this node
|
|
183
|
-
* itself, DISCONNECTED (with IMPLEMENTATION_SPECIFIC and a consistent PRECEDING or FOLLOWING) for a node in another tree,
|
|
184
|
-
* CONTAINS + PRECEDING when the other node is an ancestor, CONTAINED_BY + FOLLOWING when it is a descendant,
|
|
185
|
-
* otherwise PRECEDING or FOLLOWING by their order in the tree.
|
|
186
|
-
* @param {PseudoNode} otherNode The node to locate
|
|
187
|
-
* @returns {number}
|
|
188
|
-
*/
|
|
189
|
-
compareDocumentPosition(otherNode: PseudoNode): number;
|
|
190
|
-
/**
|
|
191
|
-
* Check whether a node is this node or one of its descendants.
|
|
192
|
-
* @param {PseudoNode|null} otherNode The node to look for
|
|
193
|
-
* @returns {boolean}
|
|
194
|
-
*/
|
|
195
|
-
contains(otherNode: PseudoNode | null): boolean;
|
|
196
|
-
getRootNode(options?: {
|
|
197
|
-
composed: boolean;
|
|
198
|
-
}): PseudoNode;
|
|
199
|
-
hasChildNodes(): boolean;
|
|
200
|
-
/**
|
|
201
|
-
* Insert a node as a child of this node, before the given child (or at the end when there is none). A node which is
|
|
202
|
-
* already in a tree is moved, and the children of a document fragment are moved in order.
|
|
203
|
-
* @param {PseudoNode} newNode The node to insert
|
|
204
|
-
* @param {PseudoNode|null} [referenceNode=null] The child of this node to insert before, or null to insert at the end
|
|
205
|
-
* @returns {PseudoNode} The inserted node
|
|
206
|
-
* @throws {Error} When the reference node is not a child of this node, or the new node is this node or contains it
|
|
207
|
-
*/
|
|
208
|
-
insertBefore(newNode: PseudoNode, referenceNode?: PseudoNode | null): PseudoNode | PseudoDocumentFragment;
|
|
209
|
-
isDefaultNamespace(namespaceURI: string | null): boolean;
|
|
210
|
-
/**
|
|
211
|
-
* Whether another node is the same as this one, by what they hold: the same type, name and value (an element also
|
|
212
|
-
* needs the same attributes), and children which are equal in the same order.
|
|
213
|
-
* @param {PseudoNode|null} otherNode The node to compare with
|
|
214
|
-
* @returns {boolean}
|
|
215
|
-
*/
|
|
216
|
-
isEqualNode(otherNode: PseudoNode | null): boolean;
|
|
217
|
-
isSameNode(otherNode: PseudoNode): boolean;
|
|
218
|
-
lookupPrefix(namespace: string): string | null;
|
|
219
|
-
lookupNamespaceURI(prefix: string): string | null;
|
|
220
|
-
/**
|
|
221
|
-
* Tidy the text below this node: neighbouring text nodes are joined into one and empty text nodes are removed.
|
|
222
|
-
*/
|
|
223
|
-
normalize(): void;
|
|
224
|
-
/**
|
|
225
|
-
* Remove a child from this node, it no longer has a parent or siblings afterwards.
|
|
226
|
-
* @param {PseudoNode} childElement The child node to remove
|
|
227
|
-
* @returns {PseudoNode} The removed node
|
|
228
|
-
* @throws {Error} When the node is not a child of this node
|
|
229
|
-
*/
|
|
230
|
-
removeChild(childElement: PseudoNode): PseudoNode;
|
|
231
|
-
/**
|
|
232
|
-
* Replace a child of this node with another node (which is moved if it is already in a tree).
|
|
233
|
-
* @param {PseudoNode} newChild The node which takes the place
|
|
234
|
-
* @param {PseudoNode} oldChild The child of this node to replace
|
|
235
|
-
* @returns {PseudoNode} The replaced node
|
|
236
|
-
* @throws {Error} When the old node is not a child of this node
|
|
237
|
-
*/
|
|
238
|
-
replaceChild(newChild: PseudoNode, oldChild: PseudoNode): PseudoNode;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Simulate the behaviour of the Text Class when there is no DOM available: the text in an element.
|
|
242
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
243
|
-
* @class
|
|
244
|
-
* @augments NodeService
|
|
245
|
-
* @property {string} data - The text
|
|
246
|
-
* @property {number} length - How many characters there are
|
|
247
|
-
* @property {string} wholeText - The text of this node and of the text nodes next to it
|
|
248
|
-
*/
|
|
249
|
-
export declare class TextService extends NodeService {
|
|
250
|
-
/**
|
|
251
|
-
* @param {string} [data=''] The text
|
|
252
|
-
* @constructor
|
|
253
|
-
*/
|
|
254
|
-
constructor(data?: string);
|
|
255
|
-
protected get acceptsChildren(): boolean;
|
|
256
|
-
get nodeName(): string;
|
|
257
|
-
get nodeType(): number;
|
|
258
|
-
get data(): string;
|
|
259
|
-
set data(data: string);
|
|
260
|
-
get length(): number;
|
|
261
|
-
get textContent(): string | null;
|
|
262
|
-
set textContent(text: string | null);
|
|
263
|
-
get wholeText(): string;
|
|
264
|
-
/**
|
|
265
|
-
* Break this text node in two at a position: this node keeps the text before it and a new node with the rest is put
|
|
266
|
-
* after this one.
|
|
267
|
-
* @param {number} offset How many characters stay in this node
|
|
268
|
-
* @returns {TextService} The new node
|
|
269
|
-
* @throws {Error} When the offset is beyond the end of the text
|
|
270
|
-
*/
|
|
271
|
-
splitText(offset: number): TextService;
|
|
272
|
-
protected cloneShallow(): NodeService;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Simulate the behaviour of the Comment Class when there is no DOM available: a note in the markup which is not shown.
|
|
276
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
277
|
-
* @class
|
|
278
|
-
* @augments NodeService
|
|
279
|
-
* @property {string} data - The comment
|
|
280
|
-
* @property {number} length - How many characters there are
|
|
281
|
-
*/
|
|
282
|
-
export declare class CommentService extends NodeService {
|
|
283
|
-
/**
|
|
284
|
-
* @param {string} [data=''] The comment
|
|
285
|
-
* @constructor
|
|
286
|
-
*/
|
|
287
|
-
constructor(data?: string);
|
|
288
|
-
protected get acceptsChildren(): boolean;
|
|
289
|
-
get nodeName(): string;
|
|
290
|
-
get nodeType(): number;
|
|
291
|
-
get data(): string;
|
|
292
|
-
set data(data: string);
|
|
293
|
-
get length(): number;
|
|
294
|
-
get textContent(): string | null;
|
|
295
|
-
set textContent(text: string | null);
|
|
296
|
-
protected cloneShallow(): NodeService;
|
|
297
|
-
}
|
|
1
|
+
import { PseudoNodeList } from '../classes/PseudoNodeList';
|
|
2
|
+
import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
|
|
3
|
+
import { TreeLinker } from 'collect-your-stuff/dist/collections/linked-tree-list/TreeLinker';
|
|
4
|
+
import { PseudoNode } from '../interfaces/PseudoNode';
|
|
5
|
+
import EventTargetService from './EventTargetService';
|
|
6
|
+
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
7
|
+
import { PseudoDocument } from '../interfaces/PseudoDocument';
|
|
8
|
+
import { PseudoDocumentFragment } from '../interfaces/PseudoDocumentFragment';
|
|
9
|
+
import { HTMLCollectionService } from './HTMLCollectionService';
|
|
10
|
+
/**
|
|
11
|
+
* Simulate the behaviour of the Node Class when there is no DOM available.
|
|
12
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
13
|
+
* @class
|
|
14
|
+
* @augments PseudoEventTarget
|
|
15
|
+
* @property {string} name
|
|
16
|
+
* @property {function} appendChild
|
|
17
|
+
* @property {function} removeChild
|
|
18
|
+
*/
|
|
19
|
+
export declare class NodeService extends EventTargetService implements PseudoNode {
|
|
20
|
+
static readonly DEFAULT_NODE = 0;
|
|
21
|
+
static readonly ELEMENT_NODE = 1;
|
|
22
|
+
static readonly ATTRIBUTE_NODE = 2;
|
|
23
|
+
static readonly TEXT_NODE = 3;
|
|
24
|
+
static readonly CDATA_SECTION_NODE = 4;
|
|
25
|
+
static readonly ENTITY_REFERENCE_NODE = 5;
|
|
26
|
+
static readonly ENTITY_NODE = 6;
|
|
27
|
+
static readonly PROCESSING_INSTRUCTION_NODE = 7;
|
|
28
|
+
static readonly COMMENT_NODE = 8;
|
|
29
|
+
static readonly DOCUMENT_NODE = 9;
|
|
30
|
+
static readonly DOCUMENT_TYPE_NODE = 10;
|
|
31
|
+
static readonly DOCUMENT_FRAGMENT_NODE = 11;
|
|
32
|
+
static readonly NOTATION_NODE = 12;
|
|
33
|
+
static readonly DOCUMENT_POSITION_DISCONNECTED = 1;
|
|
34
|
+
static readonly DOCUMENT_POSITION_PRECEDING = 2;
|
|
35
|
+
static readonly DOCUMENT_POSITION_FOLLOWING = 4;
|
|
36
|
+
static readonly DOCUMENT_POSITION_CONTAINS = 8;
|
|
37
|
+
static readonly DOCUMENT_POSITION_CONTAINED_BY = 16;
|
|
38
|
+
static readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
|
|
39
|
+
private static nextNodeId;
|
|
40
|
+
/** The raw list of every child node (all types), used to implement childNodes/firstChild/lastChild/insertBefore/removeChild. Not the same thing as Element.children (an HTMLCollection of just the element children). */
|
|
41
|
+
protected childList: PseudoNodeList | LinkedTreeList;
|
|
42
|
+
parent: PseudoNode | null;
|
|
43
|
+
protected nodeNameValue: string;
|
|
44
|
+
private nodeValueStore;
|
|
45
|
+
/** The document which made this node (createElement and the like), for when it is not in a tree yet. */
|
|
46
|
+
protected ownerDocumentStore: PseudoDocument | null;
|
|
47
|
+
/** A number for each node in the order they were made, used to give nodes which are in different trees a consistent order. */
|
|
48
|
+
private readonly nodeId;
|
|
49
|
+
/** The linker which holds this node in the children list of its parent, from which its siblings are found (null while it has no parent). */
|
|
50
|
+
protected listLinker: TreeLinker | null;
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @constructor
|
|
54
|
+
*/
|
|
55
|
+
constructor();
|
|
56
|
+
get baseURI(): Location | string;
|
|
57
|
+
get childNodes(): PseudoNodeList | LinkedTreeList;
|
|
58
|
+
get firstChild(): PseudoNode | null;
|
|
59
|
+
get isConnected(): boolean;
|
|
60
|
+
get lastChild(): PseudoNode | null;
|
|
61
|
+
get nextSibling(): PseudoNode | null;
|
|
62
|
+
get nodeName(): string;
|
|
63
|
+
get nodeType(): number;
|
|
64
|
+
get nodeValue(): string | null;
|
|
65
|
+
set nodeValue(value: string | null);
|
|
66
|
+
get ownerDocument(): PseudoDocument | null;
|
|
67
|
+
get parentNode(): PseudoNode | null;
|
|
68
|
+
get parentElement(): PseudoElement | null;
|
|
69
|
+
get previousSibling(): PseudoNode | null;
|
|
70
|
+
get textContent(): string | null;
|
|
71
|
+
set textContent(text: string | null);
|
|
72
|
+
/**
|
|
73
|
+
* Add a node as the last child of this node (a node which is already in a tree is moved).
|
|
74
|
+
* @param {PseudoNode} childNode The node to add
|
|
75
|
+
* @returns {PseudoNode} The added node
|
|
76
|
+
*/
|
|
77
|
+
appendChild(childNode: PseudoNode): PseudoNode;
|
|
78
|
+
/**
|
|
79
|
+
* Whether this kind of node can have children (text, comments and attributes cannot).
|
|
80
|
+
* @returns {boolean}
|
|
81
|
+
*/
|
|
82
|
+
protected get acceptsChildren(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Make a copy of this node without its children, its parent or its listeners, which is what cloneNode starts from.
|
|
85
|
+
* Kinds of node which are made with arguments override this to give them.
|
|
86
|
+
* @returns {NodeService}
|
|
87
|
+
*/
|
|
88
|
+
protected cloneShallow(): NodeService;
|
|
89
|
+
/**
|
|
90
|
+
* Whether another node of the same type is equal to this one apart from its children, which isEqualNode compares
|
|
91
|
+
* afterwards. Kinds of node with more to compare (an element has attributes) override this.
|
|
92
|
+
* @param {NodeService} other The node to compare with
|
|
93
|
+
* @returns {boolean}
|
|
94
|
+
*/
|
|
95
|
+
protected equalsShallow(other: NodeService): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Add nodes (strings become text nodes) as the last children of this node, in the order given.
|
|
98
|
+
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
99
|
+
* @throws {Error} When this kind of node cannot have children
|
|
100
|
+
*/
|
|
101
|
+
append(...nodes: Array<PseudoNode | string>): void;
|
|
102
|
+
/**
|
|
103
|
+
* Add nodes (strings become text nodes) as the first children of this node, in the order given.
|
|
104
|
+
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
105
|
+
* @throws {Error} When this kind of node cannot have children
|
|
106
|
+
*/
|
|
107
|
+
prepend(...nodes: Array<PseudoNode | string>): void;
|
|
108
|
+
/**
|
|
109
|
+
* Remove every child of this node and put the given nodes (strings become text nodes) in their place, in order.
|
|
110
|
+
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
111
|
+
* @throws {Error} When this kind of node cannot have children
|
|
112
|
+
*/
|
|
113
|
+
replaceChildren(...nodes: Array<PseudoNode | string>): void;
|
|
114
|
+
/**
|
|
115
|
+
* Add nodes (strings become text nodes) as this node's previous siblings, in order. Does nothing when this node has
|
|
116
|
+
* no parent.
|
|
117
|
+
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
118
|
+
*/
|
|
119
|
+
before(...nodes: Array<PseudoNode | string>): void;
|
|
120
|
+
/**
|
|
121
|
+
* Add nodes (strings become text nodes) as this node's next siblings, in order. Does nothing when this node has no
|
|
122
|
+
* parent.
|
|
123
|
+
* @param {...(PseudoNode|string)} nodes The nodes (or text) to add
|
|
124
|
+
*/
|
|
125
|
+
after(...nodes: Array<PseudoNode | string>): void;
|
|
126
|
+
/**
|
|
127
|
+
* Put the given nodes (strings become text nodes) where this node is, in order, then remove this node. Does nothing
|
|
128
|
+
* when this node has no parent.
|
|
129
|
+
* @param {...(PseudoNode|string)} nodes The nodes (or text) to put in this node's place
|
|
130
|
+
*/
|
|
131
|
+
replaceWith(...nodes: Array<PseudoNode | string>): void;
|
|
132
|
+
/**
|
|
133
|
+
* Remove this node from its parent. Does nothing when it has no parent.
|
|
134
|
+
*/
|
|
135
|
+
remove(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Turn a value given to append / prepend / before / after / replaceWith / replaceChildren into a node: a string
|
|
138
|
+
* becomes a text node belonging to this node's document, anything else is returned as it is.
|
|
139
|
+
* @param {PseudoNode|string} value The value to add
|
|
140
|
+
* @returns {PseudoNode}
|
|
141
|
+
*/
|
|
142
|
+
private toChildNode;
|
|
143
|
+
/**
|
|
144
|
+
* Every element below this node with the given tag name (or every element when tagName is *), live.
|
|
145
|
+
* @param {string} tagName
|
|
146
|
+
* @returns {PseudoHTMLCollection}
|
|
147
|
+
*/
|
|
148
|
+
getElementsByTagName(tagName: string): HTMLCollectionService;
|
|
149
|
+
/**
|
|
150
|
+
* Every element below this node which has all of the given (space separated) classes, live.
|
|
151
|
+
* @param {string} className
|
|
152
|
+
* @returns {PseudoHTMLCollection}
|
|
153
|
+
*/
|
|
154
|
+
getElementsByClassName(className: string): HTMLCollectionService;
|
|
155
|
+
/**
|
|
156
|
+
* The first element below this node which matches the CSS selector, in tree order, or null when there is none.
|
|
157
|
+
* @param {string} selectors A CSS selector
|
|
158
|
+
* @returns {PseudoElement|null}
|
|
159
|
+
*/
|
|
160
|
+
querySelector(selectors: string): PseudoElement | null;
|
|
161
|
+
/**
|
|
162
|
+
* Every element below this node which matches the CSS selector, in tree order. A plain array (not a live
|
|
163
|
+
* collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.
|
|
164
|
+
* @param {string} selectors A CSS selector
|
|
165
|
+
* @returns {Array<PseudoElement>}
|
|
166
|
+
*/
|
|
167
|
+
querySelectorAll(selectors: string): Array<PseudoElement>;
|
|
168
|
+
/**
|
|
169
|
+
* Called each time a node has been inserted as a child of this node, so that nodes which need to react to children
|
|
170
|
+
* (for example elements applying default events) can do so.
|
|
171
|
+
* @param {NodeService} child The node which was inserted
|
|
172
|
+
*/
|
|
173
|
+
protected childInserted(child: NodeService): void;
|
|
174
|
+
/**
|
|
175
|
+
* Make a copy of this node (without its parent, and without its event listeners). With deep the children are copied
|
|
176
|
+
* too, all the way down.
|
|
177
|
+
* @param {boolean} [deep=false] Copy the children as well
|
|
178
|
+
* @returns {PseudoNode}
|
|
179
|
+
*/
|
|
180
|
+
cloneNode(deep?: boolean): PseudoNode;
|
|
181
|
+
/**
|
|
182
|
+
* Say where another node is in relation to this one, as the bits of NodeService.DOCUMENT_POSITION_*: 0 for this node
|
|
183
|
+
* itself, DISCONNECTED (with IMPLEMENTATION_SPECIFIC and a consistent PRECEDING or FOLLOWING) for a node in another tree,
|
|
184
|
+
* CONTAINS + PRECEDING when the other node is an ancestor, CONTAINED_BY + FOLLOWING when it is a descendant,
|
|
185
|
+
* otherwise PRECEDING or FOLLOWING by their order in the tree.
|
|
186
|
+
* @param {PseudoNode} otherNode The node to locate
|
|
187
|
+
* @returns {number}
|
|
188
|
+
*/
|
|
189
|
+
compareDocumentPosition(otherNode: PseudoNode): number;
|
|
190
|
+
/**
|
|
191
|
+
* Check whether a node is this node or one of its descendants.
|
|
192
|
+
* @param {PseudoNode|null} otherNode The node to look for
|
|
193
|
+
* @returns {boolean}
|
|
194
|
+
*/
|
|
195
|
+
contains(otherNode: PseudoNode | null): boolean;
|
|
196
|
+
getRootNode(options?: {
|
|
197
|
+
composed: boolean;
|
|
198
|
+
}): PseudoNode;
|
|
199
|
+
hasChildNodes(): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Insert a node as a child of this node, before the given child (or at the end when there is none). A node which is
|
|
202
|
+
* already in a tree is moved, and the children of a document fragment are moved in order.
|
|
203
|
+
* @param {PseudoNode} newNode The node to insert
|
|
204
|
+
* @param {PseudoNode|null} [referenceNode=null] The child of this node to insert before, or null to insert at the end
|
|
205
|
+
* @returns {PseudoNode} The inserted node
|
|
206
|
+
* @throws {Error} When the reference node is not a child of this node, or the new node is this node or contains it
|
|
207
|
+
*/
|
|
208
|
+
insertBefore(newNode: PseudoNode, referenceNode?: PseudoNode | null): PseudoNode | PseudoDocumentFragment;
|
|
209
|
+
isDefaultNamespace(namespaceURI: string | null): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Whether another node is the same as this one, by what they hold: the same type, name and value (an element also
|
|
212
|
+
* needs the same attributes), and children which are equal in the same order.
|
|
213
|
+
* @param {PseudoNode|null} otherNode The node to compare with
|
|
214
|
+
* @returns {boolean}
|
|
215
|
+
*/
|
|
216
|
+
isEqualNode(otherNode: PseudoNode | null): boolean;
|
|
217
|
+
isSameNode(otherNode: PseudoNode): boolean;
|
|
218
|
+
lookupPrefix(namespace: string): string | null;
|
|
219
|
+
lookupNamespaceURI(prefix: string): string | null;
|
|
220
|
+
/**
|
|
221
|
+
* Tidy the text below this node: neighbouring text nodes are joined into one and empty text nodes are removed.
|
|
222
|
+
*/
|
|
223
|
+
normalize(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Remove a child from this node, it no longer has a parent or siblings afterwards.
|
|
226
|
+
* @param {PseudoNode} childElement The child node to remove
|
|
227
|
+
* @returns {PseudoNode} The removed node
|
|
228
|
+
* @throws {Error} When the node is not a child of this node
|
|
229
|
+
*/
|
|
230
|
+
removeChild(childElement: PseudoNode): PseudoNode;
|
|
231
|
+
/**
|
|
232
|
+
* Replace a child of this node with another node (which is moved if it is already in a tree).
|
|
233
|
+
* @param {PseudoNode} newChild The node which takes the place
|
|
234
|
+
* @param {PseudoNode} oldChild The child of this node to replace
|
|
235
|
+
* @returns {PseudoNode} The replaced node
|
|
236
|
+
* @throws {Error} When the old node is not a child of this node
|
|
237
|
+
*/
|
|
238
|
+
replaceChild(newChild: PseudoNode, oldChild: PseudoNode): PseudoNode;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Simulate the behaviour of the Text Class when there is no DOM available: the text in an element.
|
|
242
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
243
|
+
* @class
|
|
244
|
+
* @augments NodeService
|
|
245
|
+
* @property {string} data - The text
|
|
246
|
+
* @property {number} length - How many characters there are
|
|
247
|
+
* @property {string} wholeText - The text of this node and of the text nodes next to it
|
|
248
|
+
*/
|
|
249
|
+
export declare class TextService extends NodeService {
|
|
250
|
+
/**
|
|
251
|
+
* @param {string} [data=''] The text
|
|
252
|
+
* @constructor
|
|
253
|
+
*/
|
|
254
|
+
constructor(data?: string);
|
|
255
|
+
protected get acceptsChildren(): boolean;
|
|
256
|
+
get nodeName(): string;
|
|
257
|
+
get nodeType(): number;
|
|
258
|
+
get data(): string;
|
|
259
|
+
set data(data: string);
|
|
260
|
+
get length(): number;
|
|
261
|
+
get textContent(): string | null;
|
|
262
|
+
set textContent(text: string | null);
|
|
263
|
+
get wholeText(): string;
|
|
264
|
+
/**
|
|
265
|
+
* Break this text node in two at a position: this node keeps the text before it and a new node with the rest is put
|
|
266
|
+
* after this one.
|
|
267
|
+
* @param {number} offset How many characters stay in this node
|
|
268
|
+
* @returns {TextService} The new node
|
|
269
|
+
* @throws {Error} When the offset is beyond the end of the text
|
|
270
|
+
*/
|
|
271
|
+
splitText(offset: number): TextService;
|
|
272
|
+
protected cloneShallow(): NodeService;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Simulate the behaviour of the Comment Class when there is no DOM available: a note in the markup which is not shown.
|
|
276
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
277
|
+
* @class
|
|
278
|
+
* @augments NodeService
|
|
279
|
+
* @property {string} data - The comment
|
|
280
|
+
* @property {number} length - How many characters there are
|
|
281
|
+
*/
|
|
282
|
+
export declare class CommentService extends NodeService {
|
|
283
|
+
/**
|
|
284
|
+
* @param {string} [data=''] The comment
|
|
285
|
+
* @constructor
|
|
286
|
+
*/
|
|
287
|
+
constructor(data?: string);
|
|
288
|
+
protected get acceptsChildren(): boolean;
|
|
289
|
+
get nodeName(): string;
|
|
290
|
+
get nodeType(): number;
|
|
291
|
+
get data(): string;
|
|
292
|
+
set data(data: string);
|
|
293
|
+
get length(): number;
|
|
294
|
+
get textContent(): string | null;
|
|
295
|
+
set textContent(text: string | null);
|
|
296
|
+
protected cloneShallow(): NodeService;
|
|
297
|
+
}
|