@markuplint/ml-core 2.3.4 → 2.3.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.
- package/lib/ml-core.d.ts +1 -1
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +33 -0
- package/lib/ml-dom/manipulations/child-node-methods.js +73 -0
- package/lib/ml-dom/manipulations/get-children.d.ts +4 -0
- package/lib/ml-dom/manipulations/get-children.js +10 -0
- package/lib/ml-dom/node/attr.d.ts +98 -0
- package/lib/ml-dom/node/attr.js +157 -0
- package/lib/ml-dom/node/block.d.ts +38 -0
- package/lib/ml-dom/node/block.js +53 -0
- package/lib/ml-dom/node/character-data.d.ts +57 -0
- package/lib/ml-dom/node/character-data.js +87 -0
- package/lib/ml-dom/node/child-node.d.ts +9 -0
- package/lib/ml-dom/node/child-node.js +10 -0
- package/lib/ml-dom/node/comment.d.ts +17 -0
- package/lib/ml-dom/node/comment.js +24 -0
- package/lib/ml-dom/node/document-fragment.d.ts +24 -0
- package/lib/ml-dom/node/document-fragment.js +33 -0
- package/lib/ml-dom/node/document-type.d.ts +38 -0
- package/lib/ml-dom/node/document-type.js +52 -0
- package/lib/ml-dom/node/document.d.ts +1599 -0
- package/lib/ml-dom/node/document.js +2172 -0
- package/lib/ml-dom/node/dom-token-list.d.ts +33 -0
- package/lib/ml-dom/node/dom-token-list.js +137 -0
- package/lib/ml-dom/node/element.d.ts +1900 -0
- package/lib/ml-dom/node/element.js +2683 -0
- package/lib/ml-dom/node/named-node-map.d.ts +42 -0
- package/lib/ml-dom/node/named-node-map.js +64 -0
- package/lib/ml-dom/node/node-list.d.ts +6 -0
- package/lib/ml-dom/node/node-list.js +39 -0
- package/lib/ml-dom/node/node-store.d.ts +14 -0
- package/lib/ml-dom/node/node-store.js +32 -0
- package/lib/ml-dom/node/node.d.ts +482 -0
- package/lib/ml-dom/node/node.js +675 -0
- package/lib/ml-dom/node/parent-node.d.ts +66 -0
- package/lib/ml-dom/node/parent-node.js +131 -0
- package/lib/ml-dom/node/rule-mapper.d.ts +17 -0
- package/lib/ml-dom/node/rule-mapper.js +49 -0
- package/lib/ml-dom/node/text.d.ts +51 -0
- package/lib/ml-dom/node/text.js +76 -0
- package/lib/ml-dom/node/types.d.ts +35 -0
- package/lib/ml-dom/node/types.js +2 -0
- package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -0
- package/lib/ml-dom/node/unexpected-call-error.js +5 -0
- package/lib/ml-dom/token/token.d.ts +47 -0
- package/lib/ml-dom/token/token.js +89 -0
- package/package.json +4 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _MLNode_childNodes, _MLNode_ownerDocument, _MLNode_prevToken;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MLNode = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const token_1 = require("../token/token");
|
|
7
|
+
const child_node_1 = require("./child-node");
|
|
8
|
+
const node_list_1 = require("./node-list");
|
|
9
|
+
const node_store_1 = require("./node-store");
|
|
10
|
+
const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
|
|
11
|
+
class MLNode extends token_1.MLToken {
|
|
12
|
+
constructor(astNode, document) {
|
|
13
|
+
super(astNode);
|
|
14
|
+
/**
|
|
15
|
+
* @implements DOM API: `Node`
|
|
16
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
17
|
+
*/
|
|
18
|
+
this.ATTRIBUTE_NODE = 2;
|
|
19
|
+
/**
|
|
20
|
+
* @implements DOM API: `Node`
|
|
21
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
22
|
+
*/
|
|
23
|
+
this.CDATA_SECTION_NODE = 4;
|
|
24
|
+
/**
|
|
25
|
+
* @implements DOM API: `Node`
|
|
26
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
27
|
+
*/
|
|
28
|
+
this.COMMENT_NODE = 8;
|
|
29
|
+
/**
|
|
30
|
+
* @implements DOM API: `Node`
|
|
31
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
32
|
+
*/
|
|
33
|
+
this.DOCUMENT_FRAGMENT_NODE = 11;
|
|
34
|
+
/**
|
|
35
|
+
* @implements DOM API: `Node`
|
|
36
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
37
|
+
*/
|
|
38
|
+
this.DOCUMENT_NODE = 9;
|
|
39
|
+
/**
|
|
40
|
+
* @implements DOM API: `Node`
|
|
41
|
+
* @see https://dom.spec.whatwg.org/#dom-node-document_position_contained_by
|
|
42
|
+
*/
|
|
43
|
+
this.DOCUMENT_POSITION_CONTAINED_BY = 16;
|
|
44
|
+
/**
|
|
45
|
+
* @implements DOM API: `Node`
|
|
46
|
+
* @see https://dom.spec.whatwg.org/#dom-node-document_position_contains
|
|
47
|
+
*/
|
|
48
|
+
this.DOCUMENT_POSITION_CONTAINS = 8;
|
|
49
|
+
/**
|
|
50
|
+
* @implements DOM API: `Node`
|
|
51
|
+
* @see https://dom.spec.whatwg.org/#dom-node-document_position_disconnected
|
|
52
|
+
*/
|
|
53
|
+
this.DOCUMENT_POSITION_DISCONNECTED = 0b1;
|
|
54
|
+
/**
|
|
55
|
+
* @implements DOM API: `Node`
|
|
56
|
+
* @see https://dom.spec.whatwg.org/#dom-node-document_position_following
|
|
57
|
+
*/
|
|
58
|
+
this.DOCUMENT_POSITION_FOLLOWING = 0b100;
|
|
59
|
+
/**
|
|
60
|
+
* @implements DOM API: `Node`
|
|
61
|
+
* @see https://dom.spec.whatwg.org/#dom-node-document_position_implementation_specific
|
|
62
|
+
*/
|
|
63
|
+
this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
|
|
64
|
+
/**
|
|
65
|
+
* @implements DOM API: `Node`
|
|
66
|
+
* @see https://dom.spec.whatwg.org/#dom-node-document_position_preceding
|
|
67
|
+
*/
|
|
68
|
+
this.DOCUMENT_POSITION_PRECEDING = 0b10;
|
|
69
|
+
/**
|
|
70
|
+
* @implements DOM API: `Node`
|
|
71
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
72
|
+
*/
|
|
73
|
+
this.DOCUMENT_TYPE_NODE = 10;
|
|
74
|
+
/**
|
|
75
|
+
* @implements DOM API: `Node`
|
|
76
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
77
|
+
*/
|
|
78
|
+
this.ELEMENT_NODE = 1;
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated
|
|
81
|
+
* @implements DOM API: `Node`
|
|
82
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
83
|
+
*/
|
|
84
|
+
this.ENTITY_NODE = 6;
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated
|
|
87
|
+
* @implements DOM API: `Node`
|
|
88
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
89
|
+
*/
|
|
90
|
+
this.ENTITY_REFERENCE_NODE = 5;
|
|
91
|
+
/**
|
|
92
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
93
|
+
*/
|
|
94
|
+
this.MARKUPLINT_PREPROCESSOR_BLOCK = 101;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated
|
|
97
|
+
* @implements DOM API: `Node`
|
|
98
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
99
|
+
*/
|
|
100
|
+
this.NOTATION_NODE = 12;
|
|
101
|
+
/**
|
|
102
|
+
* @implements DOM API: `Node`
|
|
103
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
104
|
+
*/
|
|
105
|
+
this.PROCESSING_INSTRUCTION_NODE = 7;
|
|
106
|
+
/**
|
|
107
|
+
* @implements DOM API: `Node`
|
|
108
|
+
* @see https://dom.spec.whatwg.org/#interface-node
|
|
109
|
+
*/
|
|
110
|
+
this.TEXT_NODE = 3;
|
|
111
|
+
/**
|
|
112
|
+
* Cached `childNodes` property
|
|
113
|
+
*/
|
|
114
|
+
_MLNode_childNodes.set(this, void 0);
|
|
115
|
+
/**
|
|
116
|
+
* Owner `Document`
|
|
117
|
+
*
|
|
118
|
+
* @implements DOM API: `Node`
|
|
119
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument
|
|
120
|
+
*/
|
|
121
|
+
_MLNode_ownerDocument.set(this, void 0);
|
|
122
|
+
/**
|
|
123
|
+
* Cached `prevToken` property
|
|
124
|
+
*/
|
|
125
|
+
_MLNode_prevToken.set(this, void 0);
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
*/
|
|
129
|
+
this.rules = {};
|
|
130
|
+
this._astToken = astNode;
|
|
131
|
+
tslib_1.__classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
|
|
132
|
+
node_store_1.nodeStore.setNode(astNode, this);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
136
|
+
*
|
|
137
|
+
* @unsupported
|
|
138
|
+
* @implements DOM API: `Node`
|
|
139
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-baseuri%E2%91%A0
|
|
140
|
+
*/
|
|
141
|
+
get baseURI() {
|
|
142
|
+
throw new unexpected_call_error_1.default('Not supported "baseURI" property');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The list of child nodes that contains `Element`, `Text`, and `Comment`.
|
|
146
|
+
*
|
|
147
|
+
* @readonly
|
|
148
|
+
* @implements DOM API: `Node`
|
|
149
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-childnodes%E2%91%A0
|
|
150
|
+
*/
|
|
151
|
+
get childNodes() {
|
|
152
|
+
if (tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f") != null) {
|
|
153
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
|
|
154
|
+
}
|
|
155
|
+
if (this.is(this.DOCUMENT_NODE)) {
|
|
156
|
+
const childNodes = [];
|
|
157
|
+
for (const node of this.nodeList) {
|
|
158
|
+
if ((0, child_node_1.isChildNode)(node) && (node.parentNode === this || node.parentNode === null)) {
|
|
159
|
+
childNodes.push(node);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Cache
|
|
163
|
+
tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)(childNodes), "f");
|
|
164
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
|
|
165
|
+
}
|
|
166
|
+
if (this.is(this.DOCUMENT_FRAGMENT_NODE) ||
|
|
167
|
+
this.is(this.ELEMENT_NODE) ||
|
|
168
|
+
this.is(this.MARKUPLINT_PREPROCESSOR_BLOCK)) {
|
|
169
|
+
// @ts-ignore
|
|
170
|
+
const astChildren = this._astToken.childNodes || [];
|
|
171
|
+
const childNodes = astChildren
|
|
172
|
+
.map(node => node_store_1.nodeStore.getNode(node))
|
|
173
|
+
.filter((node) => (0, child_node_1.isChildNode)(node));
|
|
174
|
+
// Cache
|
|
175
|
+
tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)(childNodes), "f");
|
|
176
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
|
|
177
|
+
}
|
|
178
|
+
// Cache
|
|
179
|
+
tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, (0, node_list_1.toNodeList)([]), "f");
|
|
180
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f");
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The first node that may be `Element`, `Text`, and `CommentNode`.
|
|
184
|
+
*
|
|
185
|
+
* @readonly
|
|
186
|
+
* @implements DOM API: `Node`
|
|
187
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-firstchild%E2%91%A0
|
|
188
|
+
*/
|
|
189
|
+
get firstChild() {
|
|
190
|
+
return this.childNodes[0] || null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
194
|
+
*
|
|
195
|
+
* @unsupported
|
|
196
|
+
* @implements DOM API: `Node`
|
|
197
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-isconnected%E2%91%A0
|
|
198
|
+
*/
|
|
199
|
+
get isConnected() {
|
|
200
|
+
throw new unexpected_call_error_1.default('Not supported "isConnected" property');
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The last node that may be `Element`, `Text`, and `CommentNode`.
|
|
204
|
+
*
|
|
205
|
+
* @readonly
|
|
206
|
+
* @implements DOM API: `Node`
|
|
207
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-lastchild%E2%91%A0
|
|
208
|
+
*/
|
|
209
|
+
get lastChild() {
|
|
210
|
+
return this.childNodes[this.childNodes.length - 1] || null;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
214
|
+
*/
|
|
215
|
+
get nextNode() {
|
|
216
|
+
if (!this._astToken.nextNode) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return node_store_1.nodeStore.getNode(this._astToken.nextNode);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
223
|
+
*
|
|
224
|
+
* @unsupported
|
|
225
|
+
* @implements DOM API: `Node`
|
|
226
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-nextsibling%E2%91%A0
|
|
227
|
+
*/
|
|
228
|
+
get nextSibling() {
|
|
229
|
+
throw new unexpected_call_error_1.default('Not supported "nextSibling" property');
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
233
|
+
*
|
|
234
|
+
* It must not call from the instance of the `MLNode` class.
|
|
235
|
+
*
|
|
236
|
+
* @implements DOM API: `Node`
|
|
237
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-nodename%E2%91%A0
|
|
238
|
+
*/
|
|
239
|
+
get nodeName() {
|
|
240
|
+
throw new Error('It must not call from the instance of the `MLNode` class');
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @implements DOM API: `Node`
|
|
244
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0
|
|
245
|
+
*/
|
|
246
|
+
get nodeType() {
|
|
247
|
+
return -1;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The nodeValue getter steps are to return the following, switching on the interface this implements:
|
|
251
|
+
*
|
|
252
|
+
* - `Attr`: this’s value.
|
|
253
|
+
* - `CharacterData`: this’s data.
|
|
254
|
+
* - _Otherwise_: Null.
|
|
255
|
+
*
|
|
256
|
+
* @implements DOM API: `Node`
|
|
257
|
+
* @see https://dom.spec.whatwg.org/#dom-node-nodevalue
|
|
258
|
+
*/
|
|
259
|
+
get nodeValue() {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The `Document` that this node belongs to.
|
|
264
|
+
*
|
|
265
|
+
* @deprecated
|
|
266
|
+
* @implements DOM API: `Node`
|
|
267
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument%E2%91%A0
|
|
268
|
+
*/
|
|
269
|
+
get ownerDocument() {
|
|
270
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
|
|
271
|
+
}
|
|
272
|
+
get ownerMLDocument() {
|
|
273
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The parent element.
|
|
277
|
+
*
|
|
278
|
+
* @implements DOM API: `Node`
|
|
279
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-parentelement%E2%91%A0
|
|
280
|
+
*/
|
|
281
|
+
get parentElement() {
|
|
282
|
+
let parent = this.parentNode;
|
|
283
|
+
while (parent) {
|
|
284
|
+
if (parent.is(parent.ELEMENT_NODE)) {
|
|
285
|
+
return parent;
|
|
286
|
+
}
|
|
287
|
+
parent = parent.parentNode;
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The parent node that may be `Element`, `Document`, `DocumentFragment`, and `null`.
|
|
293
|
+
*
|
|
294
|
+
* ## HTML:
|
|
295
|
+
*
|
|
296
|
+
* ```html
|
|
297
|
+
* <html> // => #document
|
|
298
|
+
* <body></body> // => <html>
|
|
299
|
+
* </html>
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* ---
|
|
303
|
+
*
|
|
304
|
+
* ```html
|
|
305
|
+
* <div> // => null
|
|
306
|
+
* <span></span> // => <div>
|
|
307
|
+
* </div>
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* ## JSX:
|
|
311
|
+
*
|
|
312
|
+
* ```jsx
|
|
313
|
+
* <> // => null
|
|
314
|
+
* <div> // => #document-fragment
|
|
315
|
+
* {items.map(item => {
|
|
316
|
+
* return (
|
|
317
|
+
* <span /> // => null
|
|
318
|
+
* )
|
|
319
|
+
* })}
|
|
320
|
+
* </div>
|
|
321
|
+
* </>
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* ## Pug
|
|
325
|
+
*
|
|
326
|
+
* ```jade
|
|
327
|
+
* //- null
|
|
328
|
+
* div
|
|
329
|
+
* //- <div>
|
|
330
|
+
* if foo
|
|
331
|
+
* //- null
|
|
332
|
+
* span
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @implements DOM API: `Node`
|
|
336
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-parentnode%E2%91%A0
|
|
337
|
+
*/
|
|
338
|
+
get parentNode() {
|
|
339
|
+
const parentNode = this.syntacticalParentNode;
|
|
340
|
+
if (!parentNode) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
if (parentNode.is(parentNode.MARKUPLINT_PREPROCESSOR_BLOCK)) {
|
|
344
|
+
if (parentNode.isTransparent) {
|
|
345
|
+
return parentNode.parentNode;
|
|
346
|
+
}
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
if (parentNode.is(parentNode.ELEMENT_NODE) || parentNode.is(parentNode.DOCUMENT_FRAGMENT_NODE)) {
|
|
350
|
+
return parentNode;
|
|
351
|
+
}
|
|
352
|
+
if (parentNode.is(parentNode.DOCUMENT_NODE) && parentNode.isFragment) {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
return parentNode;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
359
|
+
*/
|
|
360
|
+
get prevNode() {
|
|
361
|
+
if (!this._astToken.prevNode) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
return node_store_1.nodeStore.getNode(this._astToken.prevNode);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
368
|
+
*/
|
|
369
|
+
get prevToken() {
|
|
370
|
+
if (tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f") !== undefined) {
|
|
371
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
|
|
372
|
+
}
|
|
373
|
+
let index = -1;
|
|
374
|
+
for (let i = 0; i < this.ownerMLDocument.nodeList.length; i++) {
|
|
375
|
+
const node = this.ownerMLDocument.nodeList[i];
|
|
376
|
+
if (!node) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
if (node.is(this.ELEMENT_NODE) && node.isOmitted) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (node.uuid === this.uuid) {
|
|
383
|
+
index = i;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (index === -1) {
|
|
388
|
+
tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, null, "f");
|
|
389
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f");
|
|
390
|
+
}
|
|
391
|
+
tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, this.ownerMLDocument.nodeList[index - 1] || null, "f");
|
|
392
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f") || null;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
396
|
+
*
|
|
397
|
+
* @unsupported
|
|
398
|
+
* @implements DOM API: `Node`
|
|
399
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
|
|
400
|
+
*/
|
|
401
|
+
get previousSibling() {
|
|
402
|
+
throw new unexpected_call_error_1.default('Not supported "previousSibling" property');
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
406
|
+
*/
|
|
407
|
+
get rule() {
|
|
408
|
+
if (!this.ownerMLDocument.currentRule) {
|
|
409
|
+
throw new Error('Invalid call: Some rule evaluations may not be running asynchronously.');
|
|
410
|
+
}
|
|
411
|
+
const name = this.ownerMLDocument.currentRule.name;
|
|
412
|
+
const rule = this.rules[name];
|
|
413
|
+
return this.ownerMLDocument.currentRule.optimizeOption(rule);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Returns a syntactical parent node
|
|
417
|
+
*
|
|
418
|
+
* ## HTML:
|
|
419
|
+
*
|
|
420
|
+
* ```html
|
|
421
|
+
* <html> // => #document
|
|
422
|
+
* <body></body> // => <html>
|
|
423
|
+
* </html>
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* ## JSX:
|
|
427
|
+
*
|
|
428
|
+
* ```jsx
|
|
429
|
+
* <> // => #document
|
|
430
|
+
* <div> // => #document-fragment
|
|
431
|
+
* {items.map(item => {
|
|
432
|
+
* return (
|
|
433
|
+
* <span /> // => #ml-block
|
|
434
|
+
* )
|
|
435
|
+
* })}
|
|
436
|
+
* </div>
|
|
437
|
+
* </>
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* ## Pug
|
|
441
|
+
*
|
|
442
|
+
* ```jade
|
|
443
|
+
* //- #document
|
|
444
|
+
* div
|
|
445
|
+
* //- <div>
|
|
446
|
+
* if foo
|
|
447
|
+
* //- #ml-block
|
|
448
|
+
* span
|
|
449
|
+
* ```
|
|
450
|
+
*
|
|
451
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
452
|
+
*/
|
|
453
|
+
get syntacticalParentNode() {
|
|
454
|
+
if (!this._astToken.parentNode) {
|
|
455
|
+
return this.ownerMLDocument;
|
|
456
|
+
}
|
|
457
|
+
return node_store_1.nodeStore.getNode(this._astToken.parentNode);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Return the text content.
|
|
461
|
+
*
|
|
462
|
+
* - If the node is a `Comment`, or `Text`, textContent returns, or sets, the text inside the node, i.e., the Node.nodeValue.
|
|
463
|
+
* - For other node types, textContent returns the concatenation of the textContent of every child node, excluding comments and processing instructions. (This is an empty string if the node has no children.)
|
|
464
|
+
*
|
|
465
|
+
* @implements DOM API: `Node`
|
|
466
|
+
* @see https://dom.spec.whatwg.org/#dom-node-textcontent
|
|
467
|
+
*/
|
|
468
|
+
get textContent() {
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
473
|
+
*
|
|
474
|
+
* @unsupported
|
|
475
|
+
* @implements DOM API: `EventTarget`
|
|
476
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-addeventlistener%E2%91%A2
|
|
477
|
+
*/
|
|
478
|
+
addEventListener(type, callback, options = {}) {
|
|
479
|
+
throw new unexpected_call_error_1.default('Not supported "addEventListener" method');
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
483
|
+
*
|
|
484
|
+
* @unsupported
|
|
485
|
+
* @implements DOM API: `Node`
|
|
486
|
+
* @see https://dom.spec.whatwg.org/#dom-node-appendchild
|
|
487
|
+
*/
|
|
488
|
+
appendChild(node) {
|
|
489
|
+
throw new unexpected_call_error_1.default('Not supported "appendChild" method');
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
493
|
+
*
|
|
494
|
+
* @unsupported
|
|
495
|
+
* @implements DOM API: `Node`
|
|
496
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-clonenode%E2%91%A0
|
|
497
|
+
*/
|
|
498
|
+
cloneNode(deep) {
|
|
499
|
+
throw new unexpected_call_error_1.default('Not supported "appendChild" method');
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
503
|
+
*
|
|
504
|
+
* @unsupported
|
|
505
|
+
* @implements DOM API: `Node`
|
|
506
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-comparedocumentposition%E2%91%A0
|
|
507
|
+
*/
|
|
508
|
+
compareDocumentPosition(other) {
|
|
509
|
+
throw new unexpected_call_error_1.default('Not supported "compareDocumentPosition" method');
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
513
|
+
*
|
|
514
|
+
* @unsupported
|
|
515
|
+
* @implements DOM API: `Node`
|
|
516
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-contains%E2%91%A0
|
|
517
|
+
*/
|
|
518
|
+
contains(other) {
|
|
519
|
+
throw new unexpected_call_error_1.default('Not supported "contains" method');
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
523
|
+
*
|
|
524
|
+
* @unsupported
|
|
525
|
+
* @implements DOM API: `EventTarget`
|
|
526
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-dispatchevent%E2%91%A2
|
|
527
|
+
*/
|
|
528
|
+
dispatchEvent(event) {
|
|
529
|
+
throw new unexpected_call_error_1.default('Not supported "dispatchEvent" method');
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
533
|
+
*
|
|
534
|
+
* @unsupported
|
|
535
|
+
* @implements DOM API: `Node`
|
|
536
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-getrootnode%E2%91%A0
|
|
537
|
+
*/
|
|
538
|
+
getRootNode(options) {
|
|
539
|
+
if (options) {
|
|
540
|
+
throw new unexpected_call_error_1.default('Not supported options');
|
|
541
|
+
}
|
|
542
|
+
// The original DOM API returns a document fragment if the element is a fragment.
|
|
543
|
+
return tslib_1.__classPrivateFieldGet(this, _MLNode_ownerDocument, "f");
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
547
|
+
*
|
|
548
|
+
* @unsupported
|
|
549
|
+
* @implements DOM API: `Node`
|
|
550
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-haschildnodes%E2%91%A0
|
|
551
|
+
*/
|
|
552
|
+
hasChildNodes() {
|
|
553
|
+
throw new unexpected_call_error_1.default('Not supported "hasChildNodes" method');
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
557
|
+
*
|
|
558
|
+
* @unsupported
|
|
559
|
+
* @implements DOM API: `Node`
|
|
560
|
+
* @see https://dom.spec.whatwg.org/#dom-node-insertbefore
|
|
561
|
+
*/
|
|
562
|
+
insertBefore(node, child) {
|
|
563
|
+
throw new unexpected_call_error_1.default('Not supported "insertBefore" method');
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
567
|
+
*/
|
|
568
|
+
is(nodeType) {
|
|
569
|
+
return this.nodeType === nodeType;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
573
|
+
*
|
|
574
|
+
* @unsupported
|
|
575
|
+
* @implements DOM API: `Node`
|
|
576
|
+
* @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
|
|
577
|
+
*/
|
|
578
|
+
isDefaultNamespace(namespace) {
|
|
579
|
+
throw new unexpected_call_error_1.default('Not supported "isDefaultNamespace" method');
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
583
|
+
*
|
|
584
|
+
* @unsupported
|
|
585
|
+
* @implements DOM API: `Node`
|
|
586
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-isequalnode%E2%91%A0
|
|
587
|
+
*/
|
|
588
|
+
isEqualNode(otherNode) {
|
|
589
|
+
throw new unexpected_call_error_1.default('Not supported "isEqualNode" method');
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
593
|
+
*/
|
|
594
|
+
isInFragmentDocument() {
|
|
595
|
+
return this.ownerMLDocument.isFragment;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
599
|
+
*
|
|
600
|
+
* @unsupported
|
|
601
|
+
* @implements DOM API: `Node`
|
|
602
|
+
* @see https://dom.spec.whatwg.org/#dom-node-issamenode
|
|
603
|
+
*/
|
|
604
|
+
isSameNode(otherNode) {
|
|
605
|
+
throw new unexpected_call_error_1.default('Not supported "isSameNode" method');
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
609
|
+
*
|
|
610
|
+
* @unsupported
|
|
611
|
+
* @implements DOM API: `Node`
|
|
612
|
+
* @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
|
|
613
|
+
*/
|
|
614
|
+
lookupNamespaceURI(prefix) {
|
|
615
|
+
throw new unexpected_call_error_1.default('Not supported "lookupNamespaceURI" method');
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
619
|
+
*
|
|
620
|
+
* @unsupported
|
|
621
|
+
* @implements DOM API: `Node`
|
|
622
|
+
* @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
|
|
623
|
+
*/
|
|
624
|
+
lookupPrefix(namespace) {
|
|
625
|
+
throw new unexpected_call_error_1.default('Not supported "lookupPrefix" method');
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
629
|
+
*
|
|
630
|
+
* @unsupported
|
|
631
|
+
* @implements DOM API: `Node`
|
|
632
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-node-normalize%E2%91%A0
|
|
633
|
+
*/
|
|
634
|
+
normalize() {
|
|
635
|
+
throw new unexpected_call_error_1.default('Not supported "normalize" method');
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
639
|
+
*
|
|
640
|
+
* @unsupported
|
|
641
|
+
* @implements DOM API: `Node`
|
|
642
|
+
* @see https://dom.spec.whatwg.org/#dom-node-removechild
|
|
643
|
+
*/
|
|
644
|
+
removeChild(child) {
|
|
645
|
+
throw new unexpected_call_error_1.default('Not supported "removeChild" method');
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
649
|
+
*
|
|
650
|
+
* @unsupported
|
|
651
|
+
* @implements DOM API: `EventTarget`
|
|
652
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-removeeventlistener%E2%91%A1
|
|
653
|
+
*/
|
|
654
|
+
removeEventListener(type, callback, options = {}) {
|
|
655
|
+
throw new unexpected_call_error_1.default('Not supported "removeEventListener" method');
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
659
|
+
*
|
|
660
|
+
* @unsupported
|
|
661
|
+
* @implements DOM API: `Node`
|
|
662
|
+
* @see https://dom.spec.whatwg.org/#dom-node-replacechild
|
|
663
|
+
*/
|
|
664
|
+
replaceChild(node, child) {
|
|
665
|
+
throw new unexpected_call_error_1.default('Not supported "removeChild" method');
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* @implements `@markuplint/ml-core` API: `MLNode`
|
|
669
|
+
*/
|
|
670
|
+
resetChildren(childNodes) {
|
|
671
|
+
tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, childNodes !== null && childNodes !== void 0 ? childNodes : tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
exports.MLNode = MLNode;
|
|
675
|
+
_MLNode_childNodes = new WeakMap(), _MLNode_ownerDocument = new WeakMap(), _MLNode_prevToken = new WeakMap();
|