html-react-parser 6.0.0 → 6.1.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 +35 -13
- package/dist/html-react-parser.js +1645 -1273
- package/dist/html-react-parser.js.map +1 -1
- package/dist/html-react-parser.min.js +1 -1
- package/dist/html-react-parser.min.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +2 -1
- package/lib/types.d.ts.map +1 -1
- package/package.json +22 -22
- package/src/index.ts +6 -4
- package/src/types.ts +2 -1
|
@@ -56,676 +56,469 @@
|
|
|
56
56
|
|
|
57
57
|
var htmlToDom = {};
|
|
58
58
|
|
|
59
|
-
var
|
|
59
|
+
var hasRequiredHtmlToDom;
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
function requireHtmlToDom () {
|
|
62
|
+
if (hasRequiredHtmlToDom) return htmlToDom;
|
|
63
|
+
hasRequiredHtmlToDom = 1;
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
65
|
+
Object.defineProperty(htmlToDom, '__esModule', { value: true });
|
|
66
|
+
|
|
67
|
+
/** Types of elements found in htmlparser2's DOM */
|
|
68
|
+
var ElementType;
|
|
69
|
+
(function (ElementType) {
|
|
70
|
+
/** Type for the root element of a document */
|
|
71
|
+
ElementType["Root"] = "root";
|
|
72
|
+
/** Type for Text */
|
|
73
|
+
ElementType["Text"] = "text";
|
|
74
|
+
/** Type for <? ... ?> */
|
|
75
|
+
ElementType["Directive"] = "directive";
|
|
76
|
+
/** Type for <!-- ... --> */
|
|
77
|
+
ElementType["Comment"] = "comment";
|
|
78
|
+
/** Type for <script> tags */
|
|
79
|
+
ElementType["Script"] = "script";
|
|
80
|
+
/** Type for <style> tags */
|
|
81
|
+
ElementType["Style"] = "style";
|
|
82
|
+
/** Type for Any tag */
|
|
83
|
+
ElementType["Tag"] = "tag";
|
|
84
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
85
|
+
ElementType["CDATA"] = "cdata";
|
|
86
|
+
/** Type for <!doctype ...> */
|
|
87
|
+
ElementType["Doctype"] = "doctype";
|
|
88
|
+
})(ElementType || (ElementType = {}));
|
|
89
|
+
/**
|
|
90
|
+
* Tests whether an element is a tag or not.
|
|
91
|
+
* @param element Element to test
|
|
92
|
+
* @param element.type Node type discriminator to check.
|
|
93
|
+
*/
|
|
94
|
+
function isTag$1(element) {
|
|
95
|
+
return (element.type === ElementType.Tag ||
|
|
96
|
+
element.type === ElementType.Script ||
|
|
97
|
+
element.type === ElementType.Style);
|
|
98
|
+
}
|
|
99
|
+
// Exports for backwards compatibility
|
|
100
|
+
/** Type for the root element of a document */
|
|
101
|
+
// eslint-disable-next-line prefer-destructuring
|
|
102
|
+
ElementType.Root;
|
|
103
|
+
/** Type for Text */
|
|
104
|
+
// eslint-disable-next-line prefer-destructuring
|
|
105
|
+
ElementType.Text;
|
|
106
|
+
/** Type for <? ... ?> */
|
|
107
|
+
// eslint-disable-next-line prefer-destructuring
|
|
108
|
+
ElementType.Directive;
|
|
109
|
+
/** Type for <!-- ... --> */
|
|
110
|
+
// eslint-disable-next-line prefer-destructuring
|
|
111
|
+
ElementType.Comment;
|
|
112
|
+
/** Type for <script> tags */
|
|
113
|
+
// eslint-disable-next-line prefer-destructuring
|
|
114
|
+
ElementType.Script;
|
|
115
|
+
/** Type for <style> tags */
|
|
116
|
+
// eslint-disable-next-line prefer-destructuring
|
|
117
|
+
ElementType.Style;
|
|
118
|
+
/** Type for Any tag */
|
|
119
|
+
// eslint-disable-next-line prefer-destructuring
|
|
120
|
+
ElementType.Tag;
|
|
121
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
122
|
+
// eslint-disable-next-line prefer-destructuring
|
|
123
|
+
ElementType.CDATA;
|
|
124
|
+
/** Type for <!doctype ...> */
|
|
125
|
+
// eslint-disable-next-line prefer-destructuring
|
|
126
|
+
ElementType.Doctype;
|
|
123
127
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
function cloneChildren(childs) {
|
|
475
|
-
const children = childs.map((child) => cloneNode(child, true));
|
|
476
|
-
for (let index = 1; index < children.length; index++) {
|
|
477
|
-
children[index].prev = children[index - 1];
|
|
478
|
-
children[index - 1].next = children[index];
|
|
479
|
-
}
|
|
480
|
-
return children;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Default options
|
|
484
|
-
const defaultOptions = {
|
|
485
|
-
withStartIndices: false,
|
|
486
|
-
withEndIndices: false,
|
|
487
|
-
xmlMode: false,
|
|
488
|
-
};
|
|
489
|
-
/**
|
|
490
|
-
* Event-based handler that builds a DOM tree from parser callbacks.
|
|
491
|
-
*/
|
|
492
|
-
class DomHandler {
|
|
493
|
-
/** The elements of the DOM */
|
|
494
|
-
dom = [];
|
|
495
|
-
/** The root element for the DOM */
|
|
496
|
-
root = new Document(this.dom);
|
|
497
|
-
/** Called once parsing has completed. */
|
|
498
|
-
callback;
|
|
499
|
-
/** Settings for the handler. */
|
|
500
|
-
options;
|
|
501
|
-
/** Callback whenever a tag is closed. */
|
|
502
|
-
elementCB;
|
|
503
|
-
/** Indicated whether parsing has been completed. */
|
|
504
|
-
done = false;
|
|
505
|
-
/** Stack of open tags. */
|
|
506
|
-
tagStack = [this.root];
|
|
507
|
-
/** A data node that is still being written to. */
|
|
508
|
-
lastNode = null;
|
|
509
|
-
/** Reference to the parser instance. Used for location information. */
|
|
510
|
-
parser = null;
|
|
511
|
-
/**
|
|
512
|
-
* @param callback Called once parsing has completed.
|
|
513
|
-
* @param options Settings for the handler.
|
|
514
|
-
* @param elementCB Callback whenever a tag is closed.
|
|
515
|
-
*/
|
|
516
|
-
constructor(callback, options, elementCB) {
|
|
517
|
-
// Make it possible to skip arguments, for backwards-compatibility
|
|
518
|
-
if (typeof options === "function") {
|
|
519
|
-
elementCB = options;
|
|
520
|
-
options = defaultOptions;
|
|
521
|
-
}
|
|
522
|
-
if (typeof callback === "object") {
|
|
523
|
-
options = callback;
|
|
524
|
-
callback = undefined;
|
|
525
|
-
}
|
|
526
|
-
this.callback = callback ?? null;
|
|
527
|
-
this.options = options ?? defaultOptions;
|
|
528
|
-
this.elementCB = elementCB ?? null;
|
|
529
|
-
}
|
|
530
|
-
onparserinit(parser) {
|
|
531
|
-
this.parser = parser;
|
|
532
|
-
}
|
|
533
|
-
// Resets the handler back to starting state
|
|
534
|
-
onreset() {
|
|
535
|
-
this.dom = [];
|
|
536
|
-
this.root = new Document(this.dom);
|
|
537
|
-
this.done = false;
|
|
538
|
-
this.tagStack = [this.root];
|
|
539
|
-
this.lastNode = null;
|
|
540
|
-
this.parser = null;
|
|
541
|
-
}
|
|
542
|
-
// Signals the handler that parsing is done
|
|
543
|
-
onend() {
|
|
544
|
-
if (this.done)
|
|
545
|
-
return;
|
|
546
|
-
this.done = true;
|
|
547
|
-
this.parser = null;
|
|
548
|
-
this.handleCallback(null);
|
|
549
|
-
}
|
|
550
|
-
onerror(error) {
|
|
551
|
-
this.handleCallback(error);
|
|
552
|
-
}
|
|
553
|
-
onclosetag() {
|
|
554
|
-
this.lastNode = null;
|
|
555
|
-
const element = this.tagStack.pop();
|
|
556
|
-
if (this.options.withEndIndices && this.parser) {
|
|
557
|
-
element.endIndex = this.parser.endIndex;
|
|
558
|
-
}
|
|
559
|
-
if (this.elementCB)
|
|
560
|
-
this.elementCB(element);
|
|
561
|
-
}
|
|
562
|
-
onopentag(name, attribs) {
|
|
563
|
-
const type = this.options.xmlMode ? ElementType.Tag : undefined;
|
|
564
|
-
const element = new Element(name, attribs, undefined, type);
|
|
565
|
-
this.addNode(element);
|
|
566
|
-
this.tagStack.push(element);
|
|
567
|
-
}
|
|
568
|
-
ontext(data) {
|
|
569
|
-
const { lastNode } = this;
|
|
570
|
-
if (lastNode && lastNode.type === ElementType.Text) {
|
|
571
|
-
lastNode.data += data;
|
|
572
|
-
if (this.options.withEndIndices && this.parser) {
|
|
573
|
-
lastNode.endIndex = this.parser.endIndex;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
const node = new Text(data);
|
|
578
|
-
this.addNode(node);
|
|
579
|
-
this.lastNode = node;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
oncomment(data) {
|
|
583
|
-
if (this.lastNode && this.lastNode.type === ElementType.Comment) {
|
|
584
|
-
this.lastNode.data += data;
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
const node = new Comment(data);
|
|
588
|
-
this.addNode(node);
|
|
589
|
-
this.lastNode = node;
|
|
590
|
-
}
|
|
591
|
-
oncommentend() {
|
|
592
|
-
this.lastNode = null;
|
|
593
|
-
}
|
|
594
|
-
oncdatastart() {
|
|
595
|
-
const text = new Text("");
|
|
596
|
-
const node = new CDATA([text]);
|
|
597
|
-
this.addNode(node);
|
|
598
|
-
text.parent = node;
|
|
599
|
-
this.lastNode = text;
|
|
600
|
-
}
|
|
601
|
-
oncdataend() {
|
|
602
|
-
this.lastNode = null;
|
|
603
|
-
}
|
|
604
|
-
onprocessinginstruction(name, data) {
|
|
605
|
-
const node = new ProcessingInstruction(name, data);
|
|
606
|
-
this.addNode(node);
|
|
607
|
-
}
|
|
608
|
-
handleCallback(error) {
|
|
609
|
-
if (typeof this.callback === "function") {
|
|
610
|
-
this.callback(error, this.dom);
|
|
611
|
-
}
|
|
612
|
-
else if (error) {
|
|
613
|
-
throw error;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
addNode(node) {
|
|
617
|
-
const parent = this.tagStack[this.tagStack.length - 1];
|
|
618
|
-
const previousSibling = parent.children[parent.children.length - 1];
|
|
619
|
-
if (this.options.withStartIndices && this.parser) {
|
|
620
|
-
node.startIndex = this.parser.startIndex;
|
|
621
|
-
}
|
|
622
|
-
if (this.options.withEndIndices && this.parser) {
|
|
623
|
-
node.endIndex = this.parser.endIndex;
|
|
624
|
-
}
|
|
625
|
-
parent.children.push(node);
|
|
626
|
-
if (previousSibling) {
|
|
627
|
-
node.prev = previousSibling;
|
|
628
|
-
previousSibling.next = node;
|
|
629
|
-
}
|
|
630
|
-
node.parent = parent;
|
|
631
|
-
this.lastNode = null;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
var dist = /*#__PURE__*/Object.freeze({
|
|
636
|
-
__proto__: null,
|
|
637
|
-
CDATA: CDATA,
|
|
638
|
-
Comment: Comment,
|
|
639
|
-
DataNode: DataNode,
|
|
640
|
-
Document: Document,
|
|
641
|
-
DomHandler: DomHandler,
|
|
642
|
-
Element: Element,
|
|
643
|
-
Node: Node,
|
|
644
|
-
NodeWithChildren: NodeWithChildren,
|
|
645
|
-
ProcessingInstruction: ProcessingInstruction,
|
|
646
|
-
Text: Text,
|
|
647
|
-
cloneNode: cloneNode,
|
|
648
|
-
default: DomHandler,
|
|
649
|
-
hasChildren: hasChildren,
|
|
650
|
-
isCDATA: isCDATA,
|
|
651
|
-
isComment: isComment,
|
|
652
|
-
isDirective: isDirective,
|
|
653
|
-
isDocument: isDocument,
|
|
654
|
-
isTag: isTag,
|
|
655
|
-
isText: isText
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
var require$$3 = /*@__PURE__*/getAugmentedNamespace(dist);
|
|
659
|
-
|
|
660
|
-
var constants = {};
|
|
661
|
-
|
|
662
|
-
var hasRequiredConstants;
|
|
128
|
+
/**
|
|
129
|
+
* This object will be used as the prototype for Nodes when creating a
|
|
130
|
+
* DOM-Level-1-compliant structure.
|
|
131
|
+
*/
|
|
132
|
+
class Node {
|
|
133
|
+
/** Parent of the node */
|
|
134
|
+
parent = null;
|
|
135
|
+
/** Previous sibling */
|
|
136
|
+
prev = null;
|
|
137
|
+
/** Next sibling */
|
|
138
|
+
next = null;
|
|
139
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
140
|
+
startIndex = null;
|
|
141
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
142
|
+
endIndex = null;
|
|
143
|
+
// Read-write aliases for properties
|
|
144
|
+
/**
|
|
145
|
+
* Same as {@link parent}.
|
|
146
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
147
|
+
*/
|
|
148
|
+
get parentNode() {
|
|
149
|
+
return this.parent;
|
|
150
|
+
}
|
|
151
|
+
set parentNode(parent) {
|
|
152
|
+
this.parent = parent;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Same as {@link prev}.
|
|
156
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
157
|
+
*/
|
|
158
|
+
get previousSibling() {
|
|
159
|
+
return this.prev;
|
|
160
|
+
}
|
|
161
|
+
set previousSibling(previous) {
|
|
162
|
+
this.prev = previous;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Same as {@link next}.
|
|
166
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
167
|
+
*/
|
|
168
|
+
get nextSibling() {
|
|
169
|
+
return this.next;
|
|
170
|
+
}
|
|
171
|
+
set nextSibling(next) {
|
|
172
|
+
this.next = next;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Clone this node, and optionally its children.
|
|
176
|
+
* @param recursive Clone child nodes as well.
|
|
177
|
+
* @returns A clone of the node.
|
|
178
|
+
*/
|
|
179
|
+
cloneNode(recursive = false) {
|
|
180
|
+
return cloneNode(this, recursive);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A node that contains some data.
|
|
185
|
+
*/
|
|
186
|
+
class DataNode extends Node {
|
|
187
|
+
data;
|
|
188
|
+
/**
|
|
189
|
+
* @param data The content of the data node
|
|
190
|
+
*/
|
|
191
|
+
constructor(data) {
|
|
192
|
+
super();
|
|
193
|
+
this.data = data;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Same as {@link data}.
|
|
197
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
198
|
+
*/
|
|
199
|
+
get nodeValue() {
|
|
200
|
+
return this.data;
|
|
201
|
+
}
|
|
202
|
+
set nodeValue(data) {
|
|
203
|
+
this.data = data;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Text within the document.
|
|
208
|
+
*/
|
|
209
|
+
class Text extends DataNode {
|
|
210
|
+
type = ElementType.Text;
|
|
211
|
+
get nodeType() {
|
|
212
|
+
return 3;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Comments within the document.
|
|
217
|
+
*/
|
|
218
|
+
class Comment extends DataNode {
|
|
219
|
+
type = ElementType.Comment;
|
|
220
|
+
get nodeType() {
|
|
221
|
+
return 8;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Processing instructions, including doc types.
|
|
226
|
+
*/
|
|
227
|
+
class ProcessingInstruction extends DataNode {
|
|
228
|
+
type = ElementType.Directive;
|
|
229
|
+
name;
|
|
230
|
+
constructor(name, data) {
|
|
231
|
+
super(data);
|
|
232
|
+
this.name = name;
|
|
233
|
+
}
|
|
234
|
+
get nodeType() {
|
|
235
|
+
return 1;
|
|
236
|
+
}
|
|
237
|
+
/** If this is a doctype, the document type name (parse5 only). */
|
|
238
|
+
"x-name";
|
|
239
|
+
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
240
|
+
"x-publicId";
|
|
241
|
+
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
242
|
+
"x-systemId";
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* A node that can have children.
|
|
246
|
+
*/
|
|
247
|
+
class NodeWithChildren extends Node {
|
|
248
|
+
children;
|
|
249
|
+
/**
|
|
250
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
251
|
+
*/
|
|
252
|
+
constructor(children) {
|
|
253
|
+
super();
|
|
254
|
+
this.children = children;
|
|
255
|
+
}
|
|
256
|
+
// Aliases
|
|
257
|
+
/** First child of the node. */
|
|
258
|
+
get firstChild() {
|
|
259
|
+
return this.children[0] ?? null;
|
|
260
|
+
}
|
|
261
|
+
/** Last child of the node. */
|
|
262
|
+
get lastChild() {
|
|
263
|
+
return this.children.length > 0
|
|
264
|
+
? this.children[this.children.length - 1]
|
|
265
|
+
: null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Same as {@link children}.
|
|
269
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
270
|
+
*/
|
|
271
|
+
get childNodes() {
|
|
272
|
+
return this.children;
|
|
273
|
+
}
|
|
274
|
+
set childNodes(children) {
|
|
275
|
+
this.children = children;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* CDATA nodes.
|
|
280
|
+
*/
|
|
281
|
+
class CDATA extends NodeWithChildren {
|
|
282
|
+
type = ElementType.CDATA;
|
|
283
|
+
get nodeType() {
|
|
284
|
+
return 4;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The root node of the document.
|
|
289
|
+
*/
|
|
290
|
+
class Document extends NodeWithChildren {
|
|
291
|
+
type = ElementType.Root;
|
|
292
|
+
get nodeType() {
|
|
293
|
+
return 9;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* An element within the DOM.
|
|
298
|
+
*/
|
|
299
|
+
class Element extends NodeWithChildren {
|
|
300
|
+
name;
|
|
301
|
+
attribs;
|
|
302
|
+
type;
|
|
303
|
+
/**
|
|
304
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
305
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
306
|
+
* @param children Children of the node.
|
|
307
|
+
* @param type Node type used for the new node instance.
|
|
308
|
+
*/
|
|
309
|
+
constructor(name, attribs, children = [], type = name === "script"
|
|
310
|
+
? ElementType.Script
|
|
311
|
+
: name === "style"
|
|
312
|
+
? ElementType.Style
|
|
313
|
+
: ElementType.Tag) {
|
|
314
|
+
super(children);
|
|
315
|
+
this.name = name;
|
|
316
|
+
this.attribs = attribs;
|
|
317
|
+
this.type = type;
|
|
318
|
+
}
|
|
319
|
+
get nodeType() {
|
|
320
|
+
return 1;
|
|
321
|
+
}
|
|
322
|
+
// DOM Level 1 aliases
|
|
323
|
+
/**
|
|
324
|
+
* Same as {@link name}.
|
|
325
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
326
|
+
*/
|
|
327
|
+
get tagName() {
|
|
328
|
+
return this.name;
|
|
329
|
+
}
|
|
330
|
+
set tagName(name) {
|
|
331
|
+
this.name = name;
|
|
332
|
+
}
|
|
333
|
+
get attributes() {
|
|
334
|
+
return Object.keys(this.attribs).map((name) => ({
|
|
335
|
+
name,
|
|
336
|
+
value: this.attribs[name],
|
|
337
|
+
namespace: this["x-attribsNamespace"]?.[name],
|
|
338
|
+
prefix: this["x-attribsPrefix"]?.[name],
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
/** Element namespace (parse5 only). */
|
|
342
|
+
namespace;
|
|
343
|
+
/** Element attribute namespaces (parse5 only). */
|
|
344
|
+
"x-attribsNamespace";
|
|
345
|
+
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
346
|
+
"x-attribsPrefix";
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Checks if `node` is an element node.
|
|
350
|
+
* @param node Node to check.
|
|
351
|
+
* @returns `true` if the node is an element node.
|
|
352
|
+
*/
|
|
353
|
+
function isTag(node) {
|
|
354
|
+
return isTag$1(node);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Checks if `node` is a CDATA node.
|
|
358
|
+
* @param node Node to check.
|
|
359
|
+
* @returns `true` if the node is a CDATA node.
|
|
360
|
+
*/
|
|
361
|
+
function isCDATA(node) {
|
|
362
|
+
return node.type === ElementType.CDATA;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Checks if `node` is a text node.
|
|
366
|
+
* @param node Node to check.
|
|
367
|
+
* @returns `true` if the node is a text node.
|
|
368
|
+
*/
|
|
369
|
+
function isText(node) {
|
|
370
|
+
return node.type === ElementType.Text;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Checks if `node` is a comment node.
|
|
374
|
+
* @param node Node to check.
|
|
375
|
+
* @returns `true` if the node is a comment node.
|
|
376
|
+
*/
|
|
377
|
+
function isComment(node) {
|
|
378
|
+
return node.type === ElementType.Comment;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Checks if `node` is a directive node.
|
|
382
|
+
* @param node Node to check.
|
|
383
|
+
* @returns `true` if the node is a directive node.
|
|
384
|
+
*/
|
|
385
|
+
function isDirective(node) {
|
|
386
|
+
return node.type === ElementType.Directive;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Checks if `node` is a document node.
|
|
390
|
+
* @param node Node to check.
|
|
391
|
+
* @returns `true` if the node is a document node.
|
|
392
|
+
*/
|
|
393
|
+
function isDocument(node) {
|
|
394
|
+
return node.type === ElementType.Root;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Clone a node, and optionally its children.
|
|
398
|
+
* @param node Node to clone.
|
|
399
|
+
* @param recursive Clone child nodes as well.
|
|
400
|
+
* @returns A clone of the node.
|
|
401
|
+
*/
|
|
402
|
+
function cloneNode(node, recursive = false) {
|
|
403
|
+
let result;
|
|
404
|
+
if (isText(node)) {
|
|
405
|
+
result = new Text(node.data);
|
|
406
|
+
}
|
|
407
|
+
else if (isComment(node)) {
|
|
408
|
+
result = new Comment(node.data);
|
|
409
|
+
}
|
|
410
|
+
else if (isTag(node)) {
|
|
411
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
412
|
+
const clone = new Element(node.name, { ...node.attribs }, children);
|
|
413
|
+
for (const child of children) {
|
|
414
|
+
child.parent = clone;
|
|
415
|
+
}
|
|
416
|
+
if (node.namespace != null) {
|
|
417
|
+
clone.namespace = node.namespace;
|
|
418
|
+
}
|
|
419
|
+
if (node["x-attribsNamespace"]) {
|
|
420
|
+
clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
|
|
421
|
+
}
|
|
422
|
+
if (node["x-attribsPrefix"]) {
|
|
423
|
+
clone["x-attribsPrefix"] = { ...node["x-attribsPrefix"] };
|
|
424
|
+
}
|
|
425
|
+
result = clone;
|
|
426
|
+
}
|
|
427
|
+
else if (isCDATA(node)) {
|
|
428
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
429
|
+
const clone = new CDATA(children);
|
|
430
|
+
for (const child of children) {
|
|
431
|
+
child.parent = clone;
|
|
432
|
+
}
|
|
433
|
+
result = clone;
|
|
434
|
+
}
|
|
435
|
+
else if (isDocument(node)) {
|
|
436
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
437
|
+
const clone = new Document(children);
|
|
438
|
+
for (const child of children) {
|
|
439
|
+
child.parent = clone;
|
|
440
|
+
}
|
|
441
|
+
if (node["x-mode"]) {
|
|
442
|
+
clone["x-mode"] = node["x-mode"];
|
|
443
|
+
}
|
|
444
|
+
result = clone;
|
|
445
|
+
}
|
|
446
|
+
else if (isDirective(node)) {
|
|
447
|
+
const instruction = new ProcessingInstruction(node.name, node.data);
|
|
448
|
+
if (node["x-name"] != null) {
|
|
449
|
+
instruction["x-name"] = node["x-name"];
|
|
450
|
+
instruction["x-publicId"] = node["x-publicId"];
|
|
451
|
+
instruction["x-systemId"] = node["x-systemId"];
|
|
452
|
+
}
|
|
453
|
+
result = instruction;
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
throw new Error(`Not implemented yet: ${node.type}`);
|
|
457
|
+
}
|
|
458
|
+
result.startIndex = node.startIndex;
|
|
459
|
+
result.endIndex = node.endIndex;
|
|
460
|
+
if (node.sourceCodeLocation != null) {
|
|
461
|
+
result.sourceCodeLocation = node.sourceCodeLocation;
|
|
462
|
+
}
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Clone a list of child nodes.
|
|
467
|
+
* @param childs The child nodes to clone.
|
|
468
|
+
* @returns A list of cloned child nodes.
|
|
469
|
+
*/
|
|
470
|
+
function cloneChildren(childs) {
|
|
471
|
+
const children = childs.map((child) => cloneNode(child, true));
|
|
472
|
+
for (let index = 1; index < children.length; index++) {
|
|
473
|
+
children[index].prev = children[index - 1];
|
|
474
|
+
children[index - 1].next = children[index];
|
|
475
|
+
}
|
|
476
|
+
return children;
|
|
477
|
+
}
|
|
663
478
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
'textPath',
|
|
707
|
-
];
|
|
708
|
-
exports$1.CASE_SENSITIVE_TAG_NAMES_MAP = exports$1.CASE_SENSITIVE_TAG_NAMES.reduce(function (accumulator, tagName) {
|
|
709
|
-
accumulator[tagName.toLowerCase()] = tagName;
|
|
710
|
-
return accumulator;
|
|
711
|
-
}, {});
|
|
712
|
-
|
|
713
|
-
} (constants));
|
|
714
|
-
return constants;
|
|
715
|
-
}
|
|
479
|
+
/**
|
|
480
|
+
* SVG elements are case-sensitive.
|
|
481
|
+
*
|
|
482
|
+
* @see https://developer.mozilla.org/docs/Web/SVG/Element#svg_elements_a_to_z
|
|
483
|
+
*/
|
|
484
|
+
var CASE_SENSITIVE_TAG_NAMES = [
|
|
485
|
+
'animateMotion',
|
|
486
|
+
'animateTransform',
|
|
487
|
+
'clipPath',
|
|
488
|
+
'feBlend',
|
|
489
|
+
'feColorMatrix',
|
|
490
|
+
'feComponentTransfer',
|
|
491
|
+
'feComposite',
|
|
492
|
+
'feConvolveMatrix',
|
|
493
|
+
'feDiffuseLighting',
|
|
494
|
+
'feDisplacementMap',
|
|
495
|
+
'feDropShadow',
|
|
496
|
+
'feFlood',
|
|
497
|
+
'feFuncA',
|
|
498
|
+
'feFuncB',
|
|
499
|
+
'feFuncG',
|
|
500
|
+
'feFuncR',
|
|
501
|
+
'feGaussianBlur',
|
|
502
|
+
'feImage',
|
|
503
|
+
'feMerge',
|
|
504
|
+
'feMergeNode',
|
|
505
|
+
'feMorphology',
|
|
506
|
+
'feOffset',
|
|
507
|
+
'fePointLight',
|
|
508
|
+
'feSpecularLighting',
|
|
509
|
+
'feSpotLight',
|
|
510
|
+
'feTile',
|
|
511
|
+
'feTurbulence',
|
|
512
|
+
'foreignObject',
|
|
513
|
+
'linearGradient',
|
|
514
|
+
'radialGradient',
|
|
515
|
+
'textPath',
|
|
516
|
+
];
|
|
517
|
+
var CASE_SENSITIVE_TAG_NAMES_MAP = CASE_SENSITIVE_TAG_NAMES.reduce(function (accumulator, tagName) {
|
|
518
|
+
accumulator[tagName.toLowerCase()] = tagName;
|
|
519
|
+
return accumulator;
|
|
520
|
+
}, {});
|
|
716
521
|
|
|
717
|
-
var hasRequiredUtilities$2;
|
|
718
|
-
|
|
719
|
-
function requireUtilities$2 () {
|
|
720
|
-
if (hasRequiredUtilities$2) return utilities$2;
|
|
721
|
-
hasRequiredUtilities$2 = 1;
|
|
722
|
-
Object.defineProperty(utilities$2, "__esModule", { value: true });
|
|
723
|
-
utilities$2.hasOpenTag = hasOpenTag;
|
|
724
|
-
utilities$2.escapeSpecialCharacters = escapeSpecialCharacters;
|
|
725
|
-
utilities$2.revertEscapedCharacters = revertEscapedCharacters;
|
|
726
|
-
utilities$2.formatDOM = formatDOM;
|
|
727
|
-
var domhandler_1 = require$$3;
|
|
728
|
-
var constants_1 = requireConstants();
|
|
729
522
|
var CARRIAGE_RETURN = '\r';
|
|
730
523
|
var CARRIAGE_RETURN_REGEX = new RegExp(CARRIAGE_RETURN, 'g');
|
|
731
524
|
var CARRIAGE_RETURN_PLACEHOLDER = "__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now().toString(), "__");
|
|
@@ -737,7 +530,7 @@
|
|
|
737
530
|
* @returns - Case-sensitive tag name.
|
|
738
531
|
*/
|
|
739
532
|
function getCaseSensitiveTagName(tagName) {
|
|
740
|
-
return
|
|
533
|
+
return CASE_SENSITIVE_TAG_NAMES_MAP[tagName];
|
|
741
534
|
}
|
|
742
535
|
/**
|
|
743
536
|
* Formats DOM attributes to a hash map.
|
|
@@ -833,7 +626,7 @@
|
|
|
833
626
|
case 1: {
|
|
834
627
|
var tagName = formatTagName(node.nodeName);
|
|
835
628
|
// script, style, or tag
|
|
836
|
-
current = new
|
|
629
|
+
current = new Element(tagName, formatAttributes(node.attributes));
|
|
837
630
|
current.children = formatDOM(
|
|
838
631
|
// template children are on content
|
|
839
632
|
tagName === 'template'
|
|
@@ -843,10 +636,10 @@
|
|
|
843
636
|
}
|
|
844
637
|
/* v8 ignore start */
|
|
845
638
|
case 3:
|
|
846
|
-
current = new
|
|
639
|
+
current = new Text(revertEscapedCharacters((_a = node.nodeValue) !== null && _a !== void 0 ? _a : ''));
|
|
847
640
|
break;
|
|
848
641
|
case 8:
|
|
849
|
-
current = new
|
|
642
|
+
current = new Comment((_b = node.nodeValue) !== null && _b !== void 0 ? _b : '');
|
|
850
643
|
break;
|
|
851
644
|
/* v8 ignore stop */
|
|
852
645
|
default:
|
|
@@ -865,7 +658,7 @@
|
|
|
865
658
|
domNodes.push(current);
|
|
866
659
|
}
|
|
867
660
|
if (directive) {
|
|
868
|
-
current = new
|
|
661
|
+
current = new ProcessingInstruction(directive.substring(0, directive.indexOf(' ')).toLowerCase(), directive);
|
|
869
662
|
current.next = (_d = domNodes[0]) !== null && _d !== void 0 ? _d : null;
|
|
870
663
|
current.parent = parent;
|
|
871
664
|
domNodes.unshift(current);
|
|
@@ -875,30 +668,22 @@
|
|
|
875
668
|
}
|
|
876
669
|
return domNodes;
|
|
877
670
|
}
|
|
878
|
-
|
|
879
|
-
return utilities$2;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
var hasRequiredDomparser;
|
|
883
671
|
|
|
884
|
-
function requireDomparser () {
|
|
885
|
-
if (hasRequiredDomparser) return domparser;
|
|
886
|
-
hasRequiredDomparser = 1;
|
|
887
|
-
Object.defineProperty(domparser, "__esModule", { value: true });
|
|
888
|
-
domparser.default = domparser$1;
|
|
889
|
-
var utilities_1 = requireUtilities$2();
|
|
890
672
|
// constants
|
|
891
673
|
var HTML = 'html';
|
|
892
674
|
var HEAD = 'head';
|
|
893
675
|
var BODY = 'body';
|
|
894
676
|
var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
|
|
677
|
+
function getHTMLForInnerHTML(html, trustedTypePolicy) {
|
|
678
|
+
return trustedTypePolicy ? trustedTypePolicy.createHTML(html) : html;
|
|
679
|
+
}
|
|
895
680
|
// falls back to `parseFromString` if `createHTMLDocument` cannot be used
|
|
896
681
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
897
682
|
/* v8 ignore start */
|
|
898
|
-
var parseFromDocument = function (html, tagName) {
|
|
683
|
+
var parseFromDocument = function (html, tagName, trustedTypePolicy) {
|
|
899
684
|
throw new Error('This browser does not support `document.implementation.createHTMLDocument`');
|
|
900
685
|
};
|
|
901
|
-
var parseFromString = function (html, tagName) {
|
|
686
|
+
var parseFromString = function (html, tagName, trustedTypePolicy) {
|
|
902
687
|
throw new Error('This browser does not support `DOMParser.prototype.parseFromString`');
|
|
903
688
|
};
|
|
904
689
|
var DOMParser = typeof window === 'object' && window.DOMParser;
|
|
@@ -917,7 +702,7 @@
|
|
|
917
702
|
* @param tagName - The element to render the HTML (with 'body' as fallback).
|
|
918
703
|
* @returns - Document.
|
|
919
704
|
*/
|
|
920
|
-
parseFromString = function (html, tagName) {
|
|
705
|
+
parseFromString = function (html, tagName, trustedTypePolicy) {
|
|
921
706
|
if (tagName) {
|
|
922
707
|
html = "<".concat(tagName, ">").concat(html, "</").concat(tagName, ">");
|
|
923
708
|
}
|
|
@@ -940,15 +725,15 @@
|
|
|
940
725
|
* @param tagName - The element to render the HTML (with 'body' as fallback).
|
|
941
726
|
* @returns - Document
|
|
942
727
|
*/
|
|
943
|
-
parseFromDocument = function (html, tagName) {
|
|
728
|
+
parseFromDocument = function (html, tagName, trustedTypePolicy) {
|
|
944
729
|
if (tagName) {
|
|
945
730
|
var element = htmlDocument_1.documentElement.querySelector(tagName);
|
|
946
731
|
if (element) {
|
|
947
|
-
element.innerHTML = html;
|
|
732
|
+
element.innerHTML = getHTMLForInnerHTML(html, trustedTypePolicy);
|
|
948
733
|
}
|
|
949
734
|
return htmlDocument_1;
|
|
950
735
|
}
|
|
951
|
-
htmlDocument_1.documentElement.innerHTML = html;
|
|
736
|
+
htmlDocument_1.documentElement.innerHTML = getHTMLForInnerHTML(html, trustedTypePolicy);
|
|
952
737
|
return htmlDocument_1;
|
|
953
738
|
};
|
|
954
739
|
}
|
|
@@ -967,8 +752,8 @@
|
|
|
967
752
|
* @param html - HTML string.
|
|
968
753
|
* @returns - Nodes.
|
|
969
754
|
*/
|
|
970
|
-
parseFromTemplate = function (html) {
|
|
971
|
-
template.innerHTML = html;
|
|
755
|
+
parseFromTemplate = function (html, trustedTypePolicy) {
|
|
756
|
+
template.innerHTML = getHTMLForInnerHTML(html, trustedTypePolicy);
|
|
972
757
|
return template.content.childNodes;
|
|
973
758
|
};
|
|
974
759
|
}
|
|
@@ -978,12 +763,13 @@
|
|
|
978
763
|
* Parses HTML string to DOM nodes.
|
|
979
764
|
*
|
|
980
765
|
* @param html - HTML markup.
|
|
766
|
+
* @param trustedTypePolicy - Trusted Types policy.
|
|
981
767
|
* @returns - DOM nodes.
|
|
982
768
|
*/
|
|
983
|
-
function domparser
|
|
769
|
+
function domparser(html, trustedTypePolicy) {
|
|
984
770
|
var _a, _b, _c, _d, _e, _f;
|
|
985
771
|
// Escape special characters before parsing
|
|
986
|
-
html =
|
|
772
|
+
html = escapeSpecialCharacters(html);
|
|
987
773
|
var match = FIRST_TAG_REGEX.exec(html);
|
|
988
774
|
var firstTagName = (_a = match === null || match === void 0 ? void 0 : match[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
989
775
|
switch (firstTagName) {
|
|
@@ -991,11 +777,11 @@
|
|
|
991
777
|
var doc = parseFromString(html);
|
|
992
778
|
// the created document may come with filler head/body elements,
|
|
993
779
|
// so make sure to remove them if they don't actually exist
|
|
994
|
-
if (!
|
|
780
|
+
if (!hasOpenTag(html, HEAD)) {
|
|
995
781
|
var element = doc.querySelector(HEAD);
|
|
996
782
|
(_b = element === null || element === void 0 ? void 0 : element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
|
|
997
783
|
}
|
|
998
|
-
if (!
|
|
784
|
+
if (!hasOpenTag(html, BODY)) {
|
|
999
785
|
var element = doc.querySelector(BODY);
|
|
1000
786
|
(_c = element === null || element === void 0 ? void 0 : element.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(element);
|
|
1001
787
|
}
|
|
@@ -1003,10 +789,10 @@
|
|
|
1003
789
|
}
|
|
1004
790
|
case HEAD:
|
|
1005
791
|
case BODY: {
|
|
1006
|
-
var elements = parseFromDocument(html).querySelectorAll(firstTagName);
|
|
792
|
+
var elements = parseFromDocument(html, undefined, trustedTypePolicy).querySelectorAll(firstTagName);
|
|
1007
793
|
// if there's a sibling element, then return both elements
|
|
1008
794
|
/* v8 ignore next */
|
|
1009
|
-
if (
|
|
795
|
+
if (hasOpenTag(html, BODY) && hasOpenTag(html, HEAD)) {
|
|
1010
796
|
return (_e = (_d = elements[0].parentNode) === null || _d === void 0 ? void 0 : _d.childNodes) !== null && _e !== void 0 ? _e : createNodeList();
|
|
1011
797
|
}
|
|
1012
798
|
return elements;
|
|
@@ -1016,38 +802,24 @@
|
|
|
1016
802
|
default: {
|
|
1017
803
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1018
804
|
if (parseFromTemplate) {
|
|
1019
|
-
return parseFromTemplate(html);
|
|
805
|
+
return parseFromTemplate(html, trustedTypePolicy);
|
|
1020
806
|
}
|
|
1021
|
-
var element = parseFromDocument(html, BODY).querySelector(BODY);
|
|
807
|
+
var element = parseFromDocument(html, BODY, trustedTypePolicy).querySelector(BODY);
|
|
1022
808
|
return (_f = element === null || element === void 0 ? void 0 : element.childNodes) !== null && _f !== void 0 ? _f : createNodeList();
|
|
1023
809
|
}
|
|
1024
810
|
/* v8 ignore stop */
|
|
1025
811
|
}
|
|
1026
812
|
}
|
|
1027
|
-
|
|
1028
|
-
return domparser;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
var hasRequiredHtmlToDom;
|
|
1032
813
|
|
|
1033
|
-
function requireHtmlToDom () {
|
|
1034
|
-
if (hasRequiredHtmlToDom) return htmlToDom;
|
|
1035
|
-
hasRequiredHtmlToDom = 1;
|
|
1036
|
-
var __importDefault = (htmlToDom && htmlToDom.__importDefault) || function (mod) {
|
|
1037
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1038
|
-
};
|
|
1039
|
-
Object.defineProperty(htmlToDom, "__esModule", { value: true });
|
|
1040
|
-
htmlToDom.default = HTMLDOMParser;
|
|
1041
|
-
var domparser_1 = __importDefault(requireDomparser());
|
|
1042
|
-
var utilities_1 = requireUtilities$2();
|
|
1043
814
|
var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
|
|
1044
815
|
/**
|
|
1045
816
|
* Parses HTML string to DOM nodes in browser.
|
|
1046
817
|
*
|
|
1047
818
|
* @param html - HTML markup.
|
|
819
|
+
* @param options - Parser options.
|
|
1048
820
|
* @returns - DOM elements.
|
|
1049
821
|
*/
|
|
1050
|
-
function HTMLDOMParser(html) {
|
|
822
|
+
function HTMLDOMParser(html, options) {
|
|
1051
823
|
if (typeof html !== 'string') {
|
|
1052
824
|
throw new TypeError('First argument must be a string');
|
|
1053
825
|
}
|
|
@@ -1057,8 +829,10 @@
|
|
|
1057
829
|
// match directive
|
|
1058
830
|
var match = DIRECTIVE_REGEX.exec(html);
|
|
1059
831
|
var directive = match ? match[1] : undefined;
|
|
1060
|
-
return
|
|
832
|
+
return formatDOM(domparser(html, options === null || options === void 0 ? void 0 : options.trustedTypePolicy), null, directive);
|
|
1061
833
|
}
|
|
834
|
+
|
|
835
|
+
htmlToDom.default = HTMLDOMParser;
|
|
1062
836
|
|
|
1063
837
|
return htmlToDom;
|
|
1064
838
|
}
|
|
@@ -2258,607 +2032,1204 @@
|
|
|
2258
2032
|
rules.push(c);
|
|
2259
2033
|
}
|
|
2260
2034
|
}
|
|
2261
|
-
return rules;
|
|
2262
|
-
}
|
|
2035
|
+
return rules;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* Parse comment.
|
|
2040
|
+
*
|
|
2041
|
+
* @return {Object}
|
|
2042
|
+
* @throws {Error}
|
|
2043
|
+
*/
|
|
2044
|
+
function comment() {
|
|
2045
|
+
var pos = position();
|
|
2046
|
+
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
2047
|
+
|
|
2048
|
+
var i = 2;
|
|
2049
|
+
while (
|
|
2050
|
+
EMPTY_STRING != style.charAt(i) &&
|
|
2051
|
+
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
|
2052
|
+
) {
|
|
2053
|
+
++i;
|
|
2054
|
+
}
|
|
2055
|
+
i += 2;
|
|
2056
|
+
|
|
2057
|
+
if (EMPTY_STRING === style.charAt(i - 1)) {
|
|
2058
|
+
return error('End of comment missing');
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
var str = style.slice(2, i - 2);
|
|
2062
|
+
column += 2;
|
|
2063
|
+
updatePosition(str);
|
|
2064
|
+
style = style.slice(i);
|
|
2065
|
+
column += 2;
|
|
2066
|
+
|
|
2067
|
+
return pos({
|
|
2068
|
+
type: TYPE_COMMENT,
|
|
2069
|
+
comment: str
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/**
|
|
2074
|
+
* Parse declaration.
|
|
2075
|
+
*
|
|
2076
|
+
* @return {Object}
|
|
2077
|
+
* @throws {Error}
|
|
2078
|
+
*/
|
|
2079
|
+
function declaration() {
|
|
2080
|
+
var pos = position();
|
|
2081
|
+
|
|
2082
|
+
// prop
|
|
2083
|
+
var prop = match(PROPERTY_REGEX);
|
|
2084
|
+
if (!prop) return;
|
|
2085
|
+
comment();
|
|
2086
|
+
|
|
2087
|
+
// :
|
|
2088
|
+
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
2089
|
+
|
|
2090
|
+
// val
|
|
2091
|
+
var val = match(VALUE_REGEX);
|
|
2092
|
+
|
|
2093
|
+
var ret = pos({
|
|
2094
|
+
type: TYPE_DECLARATION,
|
|
2095
|
+
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
|
2096
|
+
value: val
|
|
2097
|
+
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
|
|
2098
|
+
: EMPTY_STRING
|
|
2099
|
+
});
|
|
2100
|
+
|
|
2101
|
+
// ;
|
|
2102
|
+
match(SEMICOLON_REGEX);
|
|
2103
|
+
|
|
2104
|
+
return ret;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
/**
|
|
2108
|
+
* Parse declarations.
|
|
2109
|
+
*
|
|
2110
|
+
* @return {Object[]}
|
|
2111
|
+
*/
|
|
2112
|
+
function declarations() {
|
|
2113
|
+
var decls = [];
|
|
2114
|
+
|
|
2115
|
+
comments(decls);
|
|
2116
|
+
|
|
2117
|
+
// declarations
|
|
2118
|
+
var decl;
|
|
2119
|
+
while ((decl = declaration())) {
|
|
2120
|
+
if (decl !== false) {
|
|
2121
|
+
decls.push(decl);
|
|
2122
|
+
comments(decls);
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
return decls;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
whitespace();
|
|
2130
|
+
return declarations();
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
/**
|
|
2134
|
+
* Trim `str`.
|
|
2135
|
+
*
|
|
2136
|
+
* @param {String} str
|
|
2137
|
+
* @return {String}
|
|
2138
|
+
*/
|
|
2139
|
+
function trim(str) {
|
|
2140
|
+
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
cjs$1 = index;
|
|
2144
|
+
|
|
2145
|
+
return cjs$1;
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
var hasRequiredCjs$1;
|
|
2149
|
+
|
|
2150
|
+
function requireCjs$1 () {
|
|
2151
|
+
if (hasRequiredCjs$1) return cjs$2;
|
|
2152
|
+
hasRequiredCjs$1 = 1;
|
|
2153
|
+
var __importDefault = (cjs$2 && cjs$2.__importDefault) || function (mod) {
|
|
2154
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2155
|
+
};
|
|
2156
|
+
Object.defineProperty(cjs$2, "__esModule", { value: true });
|
|
2157
|
+
cjs$2.default = StyleToObject;
|
|
2158
|
+
const inline_style_parser_1 = __importDefault(requireCjs$2());
|
|
2159
|
+
/**
|
|
2160
|
+
* Parses inline style to object.
|
|
2161
|
+
*
|
|
2162
|
+
* @param style - Inline style.
|
|
2163
|
+
* @param iterator - Iterator.
|
|
2164
|
+
* @returns - Style object or null.
|
|
2165
|
+
*
|
|
2166
|
+
* @example Parsing inline style to object:
|
|
2167
|
+
*
|
|
2168
|
+
* ```js
|
|
2169
|
+
* import parse from 'style-to-object';
|
|
2170
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
2171
|
+
* ```
|
|
2172
|
+
*/
|
|
2173
|
+
function StyleToObject(style, iterator) {
|
|
2174
|
+
let styleObject = null;
|
|
2175
|
+
if (!style || typeof style !== 'string') {
|
|
2176
|
+
return styleObject;
|
|
2177
|
+
}
|
|
2178
|
+
const declarations = (0, inline_style_parser_1.default)(style);
|
|
2179
|
+
const hasIterator = typeof iterator === 'function';
|
|
2180
|
+
declarations.forEach((declaration) => {
|
|
2181
|
+
if (declaration.type !== 'declaration') {
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
const { property, value } = declaration;
|
|
2185
|
+
if (hasIterator) {
|
|
2186
|
+
iterator(property, value, declaration);
|
|
2187
|
+
}
|
|
2188
|
+
else if (value) {
|
|
2189
|
+
styleObject = styleObject || {};
|
|
2190
|
+
styleObject[property] = value;
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
return styleObject;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
return cjs$2;
|
|
2197
|
+
}
|
|
2263
2198
|
|
|
2264
|
-
|
|
2265
|
-
* Parse comment.
|
|
2266
|
-
*
|
|
2267
|
-
* @return {Object}
|
|
2268
|
-
* @throws {Error}
|
|
2269
|
-
*/
|
|
2270
|
-
function comment() {
|
|
2271
|
-
var pos = position();
|
|
2272
|
-
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
2199
|
+
var utilities = {};
|
|
2273
2200
|
|
|
2274
|
-
|
|
2275
|
-
while (
|
|
2276
|
-
EMPTY_STRING != style.charAt(i) &&
|
|
2277
|
-
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
|
2278
|
-
) {
|
|
2279
|
-
++i;
|
|
2280
|
-
}
|
|
2281
|
-
i += 2;
|
|
2201
|
+
var hasRequiredUtilities$1;
|
|
2282
2202
|
|
|
2283
|
-
|
|
2284
|
-
|
|
2203
|
+
function requireUtilities$1 () {
|
|
2204
|
+
if (hasRequiredUtilities$1) return utilities;
|
|
2205
|
+
hasRequiredUtilities$1 = 1;
|
|
2206
|
+
Object.defineProperty(utilities, "__esModule", { value: true });
|
|
2207
|
+
utilities.camelCase = void 0;
|
|
2208
|
+
var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/;
|
|
2209
|
+
var HYPHEN_REGEX = /-([a-z])/g;
|
|
2210
|
+
var NO_HYPHEN_REGEX = /^[^-]+$/;
|
|
2211
|
+
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
|
|
2212
|
+
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
|
|
2213
|
+
/**
|
|
2214
|
+
* Checks whether to skip camelCase.
|
|
2215
|
+
*/
|
|
2216
|
+
var skipCamelCase = function (property) {
|
|
2217
|
+
return !property ||
|
|
2218
|
+
NO_HYPHEN_REGEX.test(property) ||
|
|
2219
|
+
CUSTOM_PROPERTY_REGEX.test(property);
|
|
2220
|
+
};
|
|
2221
|
+
/**
|
|
2222
|
+
* Replacer that capitalizes first character.
|
|
2223
|
+
*/
|
|
2224
|
+
var capitalize = function (match, character) {
|
|
2225
|
+
return character.toUpperCase();
|
|
2226
|
+
};
|
|
2227
|
+
/**
|
|
2228
|
+
* Replacer that removes beginning hyphen of vendor prefix property.
|
|
2229
|
+
*/
|
|
2230
|
+
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); };
|
|
2231
|
+
/**
|
|
2232
|
+
* CamelCases a CSS property.
|
|
2233
|
+
*/
|
|
2234
|
+
var camelCase = function (property, options) {
|
|
2235
|
+
if (options === void 0) { options = {}; }
|
|
2236
|
+
if (skipCamelCase(property)) {
|
|
2237
|
+
return property;
|
|
2238
|
+
}
|
|
2239
|
+
property = property.toLowerCase();
|
|
2240
|
+
if (options.reactCompat) {
|
|
2241
|
+
// `-ms` vendor prefix should not be capitalized
|
|
2242
|
+
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
|
|
2243
|
+
}
|
|
2244
|
+
else {
|
|
2245
|
+
// for non-React, remove first hyphen so vendor prefix is not capitalized
|
|
2246
|
+
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
|
|
2285
2247
|
}
|
|
2248
|
+
return property.replace(HYPHEN_REGEX, capitalize);
|
|
2249
|
+
};
|
|
2250
|
+
utilities.camelCase = camelCase;
|
|
2251
|
+
|
|
2252
|
+
return utilities;
|
|
2253
|
+
}
|
|
2286
2254
|
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
updatePosition(str);
|
|
2290
|
-
style = style.slice(i);
|
|
2291
|
-
column += 2;
|
|
2255
|
+
var cjs;
|
|
2256
|
+
var hasRequiredCjs;
|
|
2292
2257
|
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2258
|
+
function requireCjs () {
|
|
2259
|
+
if (hasRequiredCjs) return cjs;
|
|
2260
|
+
hasRequiredCjs = 1;
|
|
2261
|
+
var __importDefault = (cjs && cjs.__importDefault) || function (mod) {
|
|
2262
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2263
|
+
};
|
|
2264
|
+
var style_to_object_1 = __importDefault(requireCjs$1());
|
|
2265
|
+
var utilities_1 = requireUtilities$1();
|
|
2266
|
+
/**
|
|
2267
|
+
* Parses CSS inline style to JavaScript object (camelCased).
|
|
2268
|
+
*/
|
|
2269
|
+
function StyleToJS(style, options) {
|
|
2270
|
+
var output = {};
|
|
2271
|
+
if (!style || typeof style !== 'string') {
|
|
2272
|
+
return output;
|
|
2273
|
+
}
|
|
2274
|
+
(0, style_to_object_1.default)(style, function (property, value) {
|
|
2275
|
+
// skip CSS comment
|
|
2276
|
+
if (property && value) {
|
|
2277
|
+
output[(0, utilities_1.camelCase)(property, options)] = value;
|
|
2278
|
+
}
|
|
2296
2279
|
});
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
*/
|
|
2305
|
-
function declaration() {
|
|
2306
|
-
var pos = position();
|
|
2307
|
-
|
|
2308
|
-
// prop
|
|
2309
|
-
var prop = match(PROPERTY_REGEX);
|
|
2310
|
-
if (!prop) return;
|
|
2311
|
-
comment();
|
|
2312
|
-
|
|
2313
|
-
// :
|
|
2314
|
-
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
2280
|
+
return output;
|
|
2281
|
+
}
|
|
2282
|
+
StyleToJS.default = StyleToJS;
|
|
2283
|
+
cjs = StyleToJS;
|
|
2284
|
+
|
|
2285
|
+
return cjs;
|
|
2286
|
+
}
|
|
2315
2287
|
|
|
2316
|
-
|
|
2317
|
-
var val = match(VALUE_REGEX);
|
|
2288
|
+
var hasRequiredUtilities;
|
|
2318
2289
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2290
|
+
function requireUtilities () {
|
|
2291
|
+
if (hasRequiredUtilities) return utilities$1;
|
|
2292
|
+
hasRequiredUtilities = 1;
|
|
2293
|
+
(function (exports) {
|
|
2294
|
+
var __importDefault = (utilities$1 && utilities$1.__importDefault) || function (mod) {
|
|
2295
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2296
|
+
};
|
|
2297
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2298
|
+
exports.returnFirstArg = exports.canTextBeChildOfNode = exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
2299
|
+
exports.isCustomComponent = isCustomComponent;
|
|
2300
|
+
exports.setStyleProp = setStyleProp;
|
|
2301
|
+
const react_1 = require$$0;
|
|
2302
|
+
const style_to_js_1 = __importDefault(requireCjs());
|
|
2303
|
+
const RESERVED_SVG_MATHML_ELEMENTS = new Set([
|
|
2304
|
+
'annotation-xml',
|
|
2305
|
+
'color-profile',
|
|
2306
|
+
'font-face',
|
|
2307
|
+
'font-face-src',
|
|
2308
|
+
'font-face-uri',
|
|
2309
|
+
'font-face-format',
|
|
2310
|
+
'font-face-name',
|
|
2311
|
+
'missing-glyph',
|
|
2312
|
+
]);
|
|
2313
|
+
/**
|
|
2314
|
+
* Check if a tag is a custom component.
|
|
2315
|
+
*
|
|
2316
|
+
* @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
|
|
2317
|
+
*
|
|
2318
|
+
* @param tagName - Tag name.
|
|
2319
|
+
* @param props - Props passed to the element.
|
|
2320
|
+
* @returns - Whether the tag is custom component.
|
|
2321
|
+
*/
|
|
2322
|
+
function isCustomComponent(tagName, props) {
|
|
2323
|
+
if (!tagName.includes('-')) {
|
|
2324
|
+
return Boolean(props && typeof props.is === 'string');
|
|
2325
|
+
}
|
|
2326
|
+
// These are reserved SVG and MathML elements.
|
|
2327
|
+
// We don't mind this whitelist too much because we expect it to never grow.
|
|
2328
|
+
// The alternative is to track the namespace in a few places which is convoluted.
|
|
2329
|
+
// https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
|
|
2330
|
+
if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) {
|
|
2331
|
+
return false;
|
|
2332
|
+
}
|
|
2333
|
+
return true;
|
|
2334
|
+
}
|
|
2335
|
+
const styleOptions = {
|
|
2336
|
+
reactCompat: true,
|
|
2337
|
+
};
|
|
2338
|
+
/**
|
|
2339
|
+
* Sets style prop.
|
|
2340
|
+
*
|
|
2341
|
+
* @param style - Inline style.
|
|
2342
|
+
* @param props - Props object.
|
|
2343
|
+
*/
|
|
2344
|
+
function setStyleProp(style, props) {
|
|
2345
|
+
if (typeof style !== 'string') {
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2348
|
+
if (!style.trim()) {
|
|
2349
|
+
props.style = {};
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
try {
|
|
2353
|
+
props.style = (0, style_to_js_1.default)(style, styleOptions);
|
|
2354
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2355
|
+
}
|
|
2356
|
+
catch (error) {
|
|
2357
|
+
props.style = {};
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
/**
|
|
2361
|
+
* @see https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html
|
|
2362
|
+
*/
|
|
2363
|
+
exports.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
|
|
2364
|
+
/**
|
|
2365
|
+
* @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
|
|
2366
|
+
*/
|
|
2367
|
+
exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
2368
|
+
'tr',
|
|
2369
|
+
'tbody',
|
|
2370
|
+
'thead',
|
|
2371
|
+
'tfoot',
|
|
2372
|
+
'colgroup',
|
|
2373
|
+
'table',
|
|
2374
|
+
'head',
|
|
2375
|
+
'html',
|
|
2376
|
+
'frameset',
|
|
2377
|
+
]);
|
|
2378
|
+
/**
|
|
2379
|
+
* Checks if the given node can contain text nodes
|
|
2380
|
+
*
|
|
2381
|
+
* @param node - Element node.
|
|
2382
|
+
* @returns - Whether the node can contain text nodes.
|
|
2383
|
+
*/
|
|
2384
|
+
const canTextBeChildOfNode = (node) => !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2385
|
+
exports.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2386
|
+
/**
|
|
2387
|
+
* Returns the first argument as is.
|
|
2388
|
+
*
|
|
2389
|
+
* @param arg - The argument to be returned.
|
|
2390
|
+
* @returns - The input argument `arg`.
|
|
2391
|
+
*/
|
|
2392
|
+
const returnFirstArg = (arg) => arg;
|
|
2393
|
+
exports.returnFirstArg = returnFirstArg;
|
|
2394
|
+
|
|
2395
|
+
} (utilities$1));
|
|
2396
|
+
return utilities$1;
|
|
2397
|
+
}
|
|
2326
2398
|
|
|
2327
|
-
|
|
2328
|
-
match(SEMICOLON_REGEX);
|
|
2399
|
+
var hasRequiredAttributesToProps;
|
|
2329
2400
|
|
|
2330
|
-
|
|
2331
|
-
|
|
2401
|
+
function requireAttributesToProps () {
|
|
2402
|
+
if (hasRequiredAttributesToProps) return attributesToProps;
|
|
2403
|
+
hasRequiredAttributesToProps = 1;
|
|
2404
|
+
Object.defineProperty(attributesToProps, "__esModule", { value: true });
|
|
2405
|
+
attributesToProps.default = attributesToProps$1;
|
|
2406
|
+
const react_property_1 = requireLib$1();
|
|
2407
|
+
const utilities_1 = requireUtilities();
|
|
2408
|
+
// https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components
|
|
2409
|
+
// https://developer.mozilla.org/docs/Web/HTML/Attributes
|
|
2410
|
+
const UNCONTROLLED_COMPONENT_ATTRIBUTES = ['checked', 'value'];
|
|
2411
|
+
const UNCONTROLLED_COMPONENT_NAMES = ['input', 'select', 'textarea'];
|
|
2412
|
+
const valueOnlyInputs = {
|
|
2413
|
+
reset: true,
|
|
2414
|
+
submit: true,
|
|
2415
|
+
};
|
|
2416
|
+
/**
|
|
2417
|
+
* Converts HTML/SVG DOM attributes to React props.
|
|
2418
|
+
*
|
|
2419
|
+
* @param attributes - HTML/SVG DOM attributes.
|
|
2420
|
+
* @param nodeName - DOM node name.
|
|
2421
|
+
* @returns - React props.
|
|
2422
|
+
*/
|
|
2423
|
+
function attributesToProps$1(attributes = {}, nodeName) {
|
|
2424
|
+
const props = {};
|
|
2425
|
+
const isInputValueOnly = Boolean(attributes.type && valueOnlyInputs[attributes.type]);
|
|
2426
|
+
for (const attributeName in attributes) {
|
|
2427
|
+
const attributeValue = attributes[attributeName];
|
|
2428
|
+
// ARIA (aria-*) or custom data (data-*) attribute
|
|
2429
|
+
if ((0, react_property_1.isCustomAttribute)(attributeName)) {
|
|
2430
|
+
props[attributeName] = attributeValue;
|
|
2431
|
+
continue;
|
|
2432
|
+
}
|
|
2433
|
+
// convert HTML/SVG attribute to React prop
|
|
2434
|
+
const attributeNameLowerCased = attributeName.toLowerCase();
|
|
2435
|
+
let propName = getPropName(attributeNameLowerCased);
|
|
2436
|
+
if (propName) {
|
|
2437
|
+
const propertyInfo = (0, react_property_1.getPropertyInfo)(propName);
|
|
2438
|
+
// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
|
|
2439
|
+
if (UNCONTROLLED_COMPONENT_ATTRIBUTES.includes(propName) &&
|
|
2440
|
+
UNCONTROLLED_COMPONENT_NAMES.includes(nodeName) &&
|
|
2441
|
+
!isInputValueOnly) {
|
|
2442
|
+
propName = getPropName('default' + attributeNameLowerCased);
|
|
2443
|
+
}
|
|
2444
|
+
props[propName] = attributeValue;
|
|
2445
|
+
switch (propertyInfo === null || propertyInfo === void 0 ? void 0 : propertyInfo.type) {
|
|
2446
|
+
case react_property_1.BOOLEAN:
|
|
2447
|
+
props[propName] = true;
|
|
2448
|
+
break;
|
|
2449
|
+
case react_property_1.OVERLOADED_BOOLEAN:
|
|
2450
|
+
if (attributeValue === '') {
|
|
2451
|
+
props[propName] = true;
|
|
2452
|
+
}
|
|
2453
|
+
break;
|
|
2454
|
+
}
|
|
2455
|
+
continue;
|
|
2456
|
+
}
|
|
2457
|
+
// preserve custom attribute if React >=16
|
|
2458
|
+
if (utilities_1.PRESERVE_CUSTOM_ATTRIBUTES) {
|
|
2459
|
+
props[attributeName] = attributeValue;
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
// transform inline style to object
|
|
2463
|
+
(0, utilities_1.setStyleProp)(attributes.style, props);
|
|
2464
|
+
return props;
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Gets prop name from lowercased attribute name.
|
|
2468
|
+
*
|
|
2469
|
+
* @param attributeName - Lowercased attribute name.
|
|
2470
|
+
* @returns - Prop name.
|
|
2471
|
+
*/
|
|
2472
|
+
function getPropName(attributeName) {
|
|
2473
|
+
return react_property_1.possibleStandardNames[attributeName];
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
return attributesToProps;
|
|
2477
|
+
}
|
|
2332
2478
|
|
|
2333
|
-
|
|
2334
|
-
* Parse declarations.
|
|
2335
|
-
*
|
|
2336
|
-
* @return {Object[]}
|
|
2337
|
-
*/
|
|
2338
|
-
function declarations() {
|
|
2339
|
-
var decls = [];
|
|
2479
|
+
var domToReact = {};
|
|
2340
2480
|
|
|
2341
|
-
|
|
2481
|
+
var hasRequiredDomToReact;
|
|
2342
2482
|
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2483
|
+
function requireDomToReact () {
|
|
2484
|
+
if (hasRequiredDomToReact) return domToReact;
|
|
2485
|
+
hasRequiredDomToReact = 1;
|
|
2486
|
+
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
|
|
2487
|
+
var __importDefault = (domToReact && domToReact.__importDefault) || function (mod) {
|
|
2488
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2489
|
+
};
|
|
2490
|
+
Object.defineProperty(domToReact, "__esModule", { value: true });
|
|
2491
|
+
domToReact.default = domToReact$1;
|
|
2492
|
+
const react_1 = require$$0;
|
|
2493
|
+
const attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
2494
|
+
const utilities_1 = requireUtilities();
|
|
2495
|
+
const React = {
|
|
2496
|
+
cloneElement: react_1.cloneElement,
|
|
2497
|
+
createElement: react_1.createElement,
|
|
2498
|
+
isValidElement: react_1.isValidElement,
|
|
2499
|
+
};
|
|
2500
|
+
/**
|
|
2501
|
+
* Converts DOM nodes to JSX element(s).
|
|
2502
|
+
*
|
|
2503
|
+
* @param nodes - DOM nodes.
|
|
2504
|
+
* @param options - Options.
|
|
2505
|
+
* @returns - String or JSX element(s).
|
|
2506
|
+
*/
|
|
2507
|
+
function domToReact$1(nodes, options = {}) {
|
|
2508
|
+
var _a, _b, _c, _d, _e;
|
|
2509
|
+
const reactElements = [];
|
|
2510
|
+
const hasReplace = typeof options.replace === 'function';
|
|
2511
|
+
const transform = (_a = options.transform) !== null && _a !== void 0 ? _a : utilities_1.returnFirstArg;
|
|
2512
|
+
const { cloneElement, createElement, isValidElement } = (_b = options.library) !== null && _b !== void 0 ? _b : React;
|
|
2513
|
+
const nodesLength = nodes.length;
|
|
2514
|
+
for (let index = 0; index < nodesLength; index++) {
|
|
2515
|
+
const node = nodes[index];
|
|
2516
|
+
// replace with custom React element (if present)
|
|
2517
|
+
if (hasReplace) {
|
|
2518
|
+
let replaceElement = (_c = options.replace) === null || _c === void 0 ? void 0 : _c.call(options, node, index);
|
|
2519
|
+
if (isValidElement(replaceElement)) {
|
|
2520
|
+
// set "key" prop for sibling elements
|
|
2521
|
+
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
2522
|
+
if (nodesLength > 1) {
|
|
2523
|
+
replaceElement = cloneElement(replaceElement, {
|
|
2524
|
+
key: (_d = replaceElement.key) !== null && _d !== void 0 ? _d : index,
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
reactElements.push(transform(replaceElement, node, index));
|
|
2528
|
+
continue;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
if (node.type === 'text') {
|
|
2532
|
+
const isWhitespace = !node.data.trim().length;
|
|
2533
|
+
// We have a whitespace node that can't be nested in its parent
|
|
2534
|
+
// so skip it
|
|
2535
|
+
if (isWhitespace &&
|
|
2536
|
+
node.parent &&
|
|
2537
|
+
!(0, utilities_1.canTextBeChildOfNode)(node.parent)) {
|
|
2538
|
+
continue;
|
|
2539
|
+
}
|
|
2540
|
+
// Trim is enabled and we have a whitespace node
|
|
2541
|
+
// so skip it
|
|
2542
|
+
if (options.trim && isWhitespace) {
|
|
2543
|
+
continue;
|
|
2544
|
+
}
|
|
2545
|
+
// We have a text node that's not whitespace and it can be nested
|
|
2546
|
+
// in its parent so add it to the results
|
|
2547
|
+
reactElements.push(transform(node.data, node, index));
|
|
2548
|
+
continue;
|
|
2549
|
+
}
|
|
2550
|
+
const element = node;
|
|
2551
|
+
let props = {};
|
|
2552
|
+
if (skipAttributesToProps(element)) {
|
|
2553
|
+
(0, utilities_1.setStyleProp)(element.attribs.style, element.attribs);
|
|
2554
|
+
props = element.attribs;
|
|
2555
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2556
|
+
}
|
|
2557
|
+
else if (element.attribs) {
|
|
2558
|
+
props = (0, attributes_to_props_1.default)(element.attribs, element.name);
|
|
2559
|
+
}
|
|
2560
|
+
let children;
|
|
2561
|
+
switch (node.type) {
|
|
2562
|
+
case 'script':
|
|
2563
|
+
case 'style':
|
|
2564
|
+
// prevent text in <script> or <style> from being escaped
|
|
2565
|
+
// https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html
|
|
2566
|
+
if (node.children[0]) {
|
|
2567
|
+
props.dangerouslySetInnerHTML = {
|
|
2568
|
+
__html: node.children[0].data,
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2571
|
+
break;
|
|
2572
|
+
case 'tag':
|
|
2573
|
+
// setting textarea value in children is an antipattern in React
|
|
2574
|
+
// https://react.dev/reference/react-dom/components/textarea#caveats
|
|
2575
|
+
if (node.name === 'textarea' && node.children[0]) {
|
|
2576
|
+
props.defaultValue = node.children[0].data;
|
|
2577
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2578
|
+
}
|
|
2579
|
+
else if ((_e = node.children) === null || _e === void 0 ? void 0 : _e.length) {
|
|
2580
|
+
// continue recursion of creating React elements (if applicable)
|
|
2581
|
+
children = domToReact$1(node.children, options);
|
|
2582
|
+
}
|
|
2583
|
+
break;
|
|
2584
|
+
// skip all other cases (e.g., comment)
|
|
2585
|
+
default:
|
|
2586
|
+
continue;
|
|
2587
|
+
}
|
|
2588
|
+
// set "key" prop for sibling elements
|
|
2589
|
+
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
2590
|
+
if (nodesLength > 1) {
|
|
2591
|
+
props.key = index;
|
|
2592
|
+
}
|
|
2593
|
+
reactElements.push(transform(createElement(node.name, props, children), node, index));
|
|
2350
2594
|
}
|
|
2351
|
-
|
|
2352
|
-
return decls;
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
whitespace();
|
|
2356
|
-
return declarations();
|
|
2595
|
+
return reactElements.length === 1 ? reactElements[0] : reactElements;
|
|
2357
2596
|
}
|
|
2358
|
-
|
|
2359
2597
|
/**
|
|
2360
|
-
*
|
|
2598
|
+
* Determines whether DOM element attributes should be transformed to props.
|
|
2599
|
+
* Web Components should not have their attributes transformed except for `style`.
|
|
2361
2600
|
*
|
|
2362
|
-
* @param
|
|
2363
|
-
* @
|
|
2601
|
+
* @param node - Element node.
|
|
2602
|
+
* @returns - Whether the node attributes should be converted to props.
|
|
2364
2603
|
*/
|
|
2365
|
-
function
|
|
2366
|
-
|
|
2604
|
+
function skipAttributesToProps(node) {
|
|
2605
|
+
return (utilities_1.PRESERVE_CUSTOM_ATTRIBUTES &&
|
|
2606
|
+
node.type === 'tag' &&
|
|
2607
|
+
(0, utilities_1.isCustomComponent)(node.name, node.attribs));
|
|
2367
2608
|
}
|
|
2609
|
+
|
|
2610
|
+
return domToReact;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
/** Types of elements found in htmlparser2's DOM */
|
|
2614
|
+
var ElementType;
|
|
2615
|
+
(function (ElementType) {
|
|
2616
|
+
/** Type for the root element of a document */
|
|
2617
|
+
ElementType["Root"] = "root";
|
|
2618
|
+
/** Type for Text */
|
|
2619
|
+
ElementType["Text"] = "text";
|
|
2620
|
+
/** Type for <? ... ?> */
|
|
2621
|
+
ElementType["Directive"] = "directive";
|
|
2622
|
+
/** Type for <!-- ... --> */
|
|
2623
|
+
ElementType["Comment"] = "comment";
|
|
2624
|
+
/** Type for <script> tags */
|
|
2625
|
+
ElementType["Script"] = "script";
|
|
2626
|
+
/** Type for <style> tags */
|
|
2627
|
+
ElementType["Style"] = "style";
|
|
2628
|
+
/** Type for Any tag */
|
|
2629
|
+
ElementType["Tag"] = "tag";
|
|
2630
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
2631
|
+
ElementType["CDATA"] = "cdata";
|
|
2632
|
+
/** Type for <!doctype ...> */
|
|
2633
|
+
ElementType["Doctype"] = "doctype";
|
|
2634
|
+
})(ElementType || (ElementType = {}));
|
|
2635
|
+
/**
|
|
2636
|
+
* Tests whether an element is a tag or not.
|
|
2637
|
+
* @param element Element to test
|
|
2638
|
+
* @param element.type Node type discriminator to check.
|
|
2639
|
+
*/
|
|
2640
|
+
function isTag$1(element) {
|
|
2641
|
+
return (element.type === ElementType.Tag ||
|
|
2642
|
+
element.type === ElementType.Script ||
|
|
2643
|
+
element.type === ElementType.Style);
|
|
2644
|
+
}
|
|
2645
|
+
// Exports for backwards compatibility
|
|
2646
|
+
/** Type for the root element of a document */
|
|
2647
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2648
|
+
ElementType.Root;
|
|
2649
|
+
/** Type for Text */
|
|
2650
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2651
|
+
ElementType.Text;
|
|
2652
|
+
/** Type for <? ... ?> */
|
|
2653
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2654
|
+
ElementType.Directive;
|
|
2655
|
+
/** Type for <!-- ... --> */
|
|
2656
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2657
|
+
ElementType.Comment;
|
|
2658
|
+
/** Type for <script> tags */
|
|
2659
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2660
|
+
ElementType.Script;
|
|
2661
|
+
/** Type for <style> tags */
|
|
2662
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2663
|
+
ElementType.Style;
|
|
2664
|
+
/** Type for Any tag */
|
|
2665
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2666
|
+
ElementType.Tag;
|
|
2667
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
2668
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2669
|
+
ElementType.CDATA;
|
|
2670
|
+
/** Type for <!doctype ...> */
|
|
2671
|
+
// eslint-disable-next-line prefer-destructuring
|
|
2672
|
+
ElementType.Doctype;
|
|
2368
2673
|
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2674
|
+
/**
|
|
2675
|
+
* This object will be used as the prototype for Nodes when creating a
|
|
2676
|
+
* DOM-Level-1-compliant structure.
|
|
2677
|
+
*/
|
|
2678
|
+
class Node {
|
|
2679
|
+
/** Parent of the node */
|
|
2680
|
+
parent = null;
|
|
2681
|
+
/** Previous sibling */
|
|
2682
|
+
prev = null;
|
|
2683
|
+
/** Next sibling */
|
|
2684
|
+
next = null;
|
|
2685
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
2686
|
+
startIndex = null;
|
|
2687
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
2688
|
+
endIndex = null;
|
|
2689
|
+
// Read-write aliases for properties
|
|
2690
|
+
/**
|
|
2691
|
+
* Same as {@link parent}.
|
|
2692
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
2693
|
+
*/
|
|
2694
|
+
get parentNode() {
|
|
2695
|
+
return this.parent;
|
|
2696
|
+
}
|
|
2697
|
+
set parentNode(parent) {
|
|
2698
|
+
this.parent = parent;
|
|
2699
|
+
}
|
|
2700
|
+
/**
|
|
2701
|
+
* Same as {@link prev}.
|
|
2702
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
2703
|
+
*/
|
|
2704
|
+
get previousSibling() {
|
|
2705
|
+
return this.prev;
|
|
2706
|
+
}
|
|
2707
|
+
set previousSibling(previous) {
|
|
2708
|
+
this.prev = previous;
|
|
2709
|
+
}
|
|
2710
|
+
/**
|
|
2711
|
+
* Same as {@link next}.
|
|
2712
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
2713
|
+
*/
|
|
2714
|
+
get nextSibling() {
|
|
2715
|
+
return this.next;
|
|
2716
|
+
}
|
|
2717
|
+
set nextSibling(next) {
|
|
2718
|
+
this.next = next;
|
|
2719
|
+
}
|
|
2720
|
+
/**
|
|
2721
|
+
* Clone this node, and optionally its children.
|
|
2722
|
+
* @param recursive Clone child nodes as well.
|
|
2723
|
+
* @returns A clone of the node.
|
|
2724
|
+
*/
|
|
2725
|
+
cloneNode(recursive = false) {
|
|
2726
|
+
return cloneNode(this, recursive);
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
/**
|
|
2730
|
+
* A node that contains some data.
|
|
2731
|
+
*/
|
|
2732
|
+
class DataNode extends Node {
|
|
2733
|
+
data;
|
|
2734
|
+
/**
|
|
2735
|
+
* @param data The content of the data node
|
|
2736
|
+
*/
|
|
2737
|
+
constructor(data) {
|
|
2738
|
+
super();
|
|
2739
|
+
this.data = data;
|
|
2740
|
+
}
|
|
2741
|
+
/**
|
|
2742
|
+
* Same as {@link data}.
|
|
2743
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
2744
|
+
*/
|
|
2745
|
+
get nodeValue() {
|
|
2746
|
+
return this.data;
|
|
2747
|
+
}
|
|
2748
|
+
set nodeValue(data) {
|
|
2749
|
+
this.data = data;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
/**
|
|
2753
|
+
* Text within the document.
|
|
2754
|
+
*/
|
|
2755
|
+
class Text extends DataNode {
|
|
2756
|
+
type = ElementType.Text;
|
|
2757
|
+
get nodeType() {
|
|
2758
|
+
return 3;
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Comments within the document.
|
|
2763
|
+
*/
|
|
2764
|
+
class Comment extends DataNode {
|
|
2765
|
+
type = ElementType.Comment;
|
|
2766
|
+
get nodeType() {
|
|
2767
|
+
return 8;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
/**
|
|
2771
|
+
* Processing instructions, including doc types.
|
|
2772
|
+
*/
|
|
2773
|
+
class ProcessingInstruction extends DataNode {
|
|
2774
|
+
type = ElementType.Directive;
|
|
2775
|
+
name;
|
|
2776
|
+
constructor(name, data) {
|
|
2777
|
+
super(data);
|
|
2778
|
+
this.name = name;
|
|
2779
|
+
}
|
|
2780
|
+
get nodeType() {
|
|
2781
|
+
return 1;
|
|
2782
|
+
}
|
|
2783
|
+
/** If this is a doctype, the document type name (parse5 only). */
|
|
2784
|
+
"x-name";
|
|
2785
|
+
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
2786
|
+
"x-publicId";
|
|
2787
|
+
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
2788
|
+
"x-systemId";
|
|
2789
|
+
}
|
|
2790
|
+
/**
|
|
2791
|
+
* A node that can have children.
|
|
2792
|
+
*/
|
|
2793
|
+
class NodeWithChildren extends Node {
|
|
2794
|
+
children;
|
|
2795
|
+
/**
|
|
2796
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
2797
|
+
*/
|
|
2798
|
+
constructor(children) {
|
|
2799
|
+
super();
|
|
2800
|
+
this.children = children;
|
|
2801
|
+
}
|
|
2802
|
+
// Aliases
|
|
2803
|
+
/** First child of the node. */
|
|
2804
|
+
get firstChild() {
|
|
2805
|
+
return this.children[0] ?? null;
|
|
2806
|
+
}
|
|
2807
|
+
/** Last child of the node. */
|
|
2808
|
+
get lastChild() {
|
|
2809
|
+
return this.children.length > 0
|
|
2810
|
+
? this.children[this.children.length - 1]
|
|
2811
|
+
: null;
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
2814
|
+
* Same as {@link children}.
|
|
2815
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
2816
|
+
*/
|
|
2817
|
+
get childNodes() {
|
|
2818
|
+
return this.children;
|
|
2819
|
+
}
|
|
2820
|
+
set childNodes(children) {
|
|
2821
|
+
this.children = children;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
/**
|
|
2825
|
+
* CDATA nodes.
|
|
2826
|
+
*/
|
|
2827
|
+
class CDATA extends NodeWithChildren {
|
|
2828
|
+
type = ElementType.CDATA;
|
|
2829
|
+
get nodeType() {
|
|
2830
|
+
return 4;
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
/**
|
|
2834
|
+
* The root node of the document.
|
|
2835
|
+
*/
|
|
2836
|
+
class Document extends NodeWithChildren {
|
|
2837
|
+
type = ElementType.Root;
|
|
2838
|
+
get nodeType() {
|
|
2839
|
+
return 9;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
/**
|
|
2843
|
+
* An element within the DOM.
|
|
2844
|
+
*/
|
|
2845
|
+
class Element extends NodeWithChildren {
|
|
2846
|
+
name;
|
|
2847
|
+
attribs;
|
|
2848
|
+
type;
|
|
2849
|
+
/**
|
|
2850
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
2851
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
2852
|
+
* @param children Children of the node.
|
|
2853
|
+
* @param type Node type used for the new node instance.
|
|
2854
|
+
*/
|
|
2855
|
+
constructor(name, attribs, children = [], type = name === "script"
|
|
2856
|
+
? ElementType.Script
|
|
2857
|
+
: name === "style"
|
|
2858
|
+
? ElementType.Style
|
|
2859
|
+
: ElementType.Tag) {
|
|
2860
|
+
super(children);
|
|
2861
|
+
this.name = name;
|
|
2862
|
+
this.attribs = attribs;
|
|
2863
|
+
this.type = type;
|
|
2864
|
+
}
|
|
2865
|
+
get nodeType() {
|
|
2866
|
+
return 1;
|
|
2867
|
+
}
|
|
2868
|
+
// DOM Level 1 aliases
|
|
2869
|
+
/**
|
|
2870
|
+
* Same as {@link name}.
|
|
2871
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
2872
|
+
*/
|
|
2873
|
+
get tagName() {
|
|
2874
|
+
return this.name;
|
|
2875
|
+
}
|
|
2876
|
+
set tagName(name) {
|
|
2877
|
+
this.name = name;
|
|
2878
|
+
}
|
|
2879
|
+
get attributes() {
|
|
2880
|
+
return Object.keys(this.attribs).map((name) => ({
|
|
2881
|
+
name,
|
|
2882
|
+
value: this.attribs[name],
|
|
2883
|
+
namespace: this["x-attribsNamespace"]?.[name],
|
|
2884
|
+
prefix: this["x-attribsPrefix"]?.[name],
|
|
2885
|
+
}));
|
|
2886
|
+
}
|
|
2887
|
+
/** Element namespace (parse5 only). */
|
|
2888
|
+
namespace;
|
|
2889
|
+
/** Element attribute namespaces (parse5 only). */
|
|
2890
|
+
"x-attribsNamespace";
|
|
2891
|
+
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
2892
|
+
"x-attribsPrefix";
|
|
2372
2893
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2381
|
-
};
|
|
2382
|
-
Object.defineProperty(cjs$2, "__esModule", { value: true });
|
|
2383
|
-
cjs$2.default = StyleToObject;
|
|
2384
|
-
const inline_style_parser_1 = __importDefault(requireCjs$2());
|
|
2385
|
-
/**
|
|
2386
|
-
* Parses inline style to object.
|
|
2387
|
-
*
|
|
2388
|
-
* @param style - Inline style.
|
|
2389
|
-
* @param iterator - Iterator.
|
|
2390
|
-
* @returns - Style object or null.
|
|
2391
|
-
*
|
|
2392
|
-
* @example Parsing inline style to object:
|
|
2393
|
-
*
|
|
2394
|
-
* ```js
|
|
2395
|
-
* import parse from 'style-to-object';
|
|
2396
|
-
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
2397
|
-
* ```
|
|
2398
|
-
*/
|
|
2399
|
-
function StyleToObject(style, iterator) {
|
|
2400
|
-
let styleObject = null;
|
|
2401
|
-
if (!style || typeof style !== 'string') {
|
|
2402
|
-
return styleObject;
|
|
2403
|
-
}
|
|
2404
|
-
const declarations = (0, inline_style_parser_1.default)(style);
|
|
2405
|
-
const hasIterator = typeof iterator === 'function';
|
|
2406
|
-
declarations.forEach((declaration) => {
|
|
2407
|
-
if (declaration.type !== 'declaration') {
|
|
2408
|
-
return;
|
|
2409
|
-
}
|
|
2410
|
-
const { property, value } = declaration;
|
|
2411
|
-
if (hasIterator) {
|
|
2412
|
-
iterator(property, value, declaration);
|
|
2413
|
-
}
|
|
2414
|
-
else if (value) {
|
|
2415
|
-
styleObject = styleObject || {};
|
|
2416
|
-
styleObject[property] = value;
|
|
2417
|
-
}
|
|
2418
|
-
});
|
|
2419
|
-
return styleObject;
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
return cjs$2;
|
|
2894
|
+
/**
|
|
2895
|
+
* Checks if `node` is an element node.
|
|
2896
|
+
* @param node Node to check.
|
|
2897
|
+
* @returns `true` if the node is an element node.
|
|
2898
|
+
*/
|
|
2899
|
+
function isTag(node) {
|
|
2900
|
+
return isTag$1(node);
|
|
2423
2901
|
}
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
function
|
|
2430
|
-
|
|
2431
|
-
hasRequiredUtilities$1 = 1;
|
|
2432
|
-
Object.defineProperty(utilities, "__esModule", { value: true });
|
|
2433
|
-
utilities.camelCase = void 0;
|
|
2434
|
-
var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/;
|
|
2435
|
-
var HYPHEN_REGEX = /-([a-z])/g;
|
|
2436
|
-
var NO_HYPHEN_REGEX = /^[^-]+$/;
|
|
2437
|
-
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
|
|
2438
|
-
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
|
|
2439
|
-
/**
|
|
2440
|
-
* Checks whether to skip camelCase.
|
|
2441
|
-
*/
|
|
2442
|
-
var skipCamelCase = function (property) {
|
|
2443
|
-
return !property ||
|
|
2444
|
-
NO_HYPHEN_REGEX.test(property) ||
|
|
2445
|
-
CUSTOM_PROPERTY_REGEX.test(property);
|
|
2446
|
-
};
|
|
2447
|
-
/**
|
|
2448
|
-
* Replacer that capitalizes first character.
|
|
2449
|
-
*/
|
|
2450
|
-
var capitalize = function (match, character) {
|
|
2451
|
-
return character.toUpperCase();
|
|
2452
|
-
};
|
|
2453
|
-
/**
|
|
2454
|
-
* Replacer that removes beginning hyphen of vendor prefix property.
|
|
2455
|
-
*/
|
|
2456
|
-
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); };
|
|
2457
|
-
/**
|
|
2458
|
-
* CamelCases a CSS property.
|
|
2459
|
-
*/
|
|
2460
|
-
var camelCase = function (property, options) {
|
|
2461
|
-
if (options === void 0) { options = {}; }
|
|
2462
|
-
if (skipCamelCase(property)) {
|
|
2463
|
-
return property;
|
|
2464
|
-
}
|
|
2465
|
-
property = property.toLowerCase();
|
|
2466
|
-
if (options.reactCompat) {
|
|
2467
|
-
// `-ms` vendor prefix should not be capitalized
|
|
2468
|
-
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
|
|
2469
|
-
}
|
|
2470
|
-
else {
|
|
2471
|
-
// for non-React, remove first hyphen so vendor prefix is not capitalized
|
|
2472
|
-
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
|
|
2473
|
-
}
|
|
2474
|
-
return property.replace(HYPHEN_REGEX, capitalize);
|
|
2475
|
-
};
|
|
2476
|
-
utilities.camelCase = camelCase;
|
|
2477
|
-
|
|
2478
|
-
return utilities;
|
|
2902
|
+
/**
|
|
2903
|
+
* Checks if `node` is a CDATA node.
|
|
2904
|
+
* @param node Node to check.
|
|
2905
|
+
* @returns `true` if the node is a CDATA node.
|
|
2906
|
+
*/
|
|
2907
|
+
function isCDATA(node) {
|
|
2908
|
+
return node.type === ElementType.CDATA;
|
|
2479
2909
|
}
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2910
|
+
/**
|
|
2911
|
+
* Checks if `node` is a text node.
|
|
2912
|
+
* @param node Node to check.
|
|
2913
|
+
* @returns `true` if the node is a text node.
|
|
2914
|
+
*/
|
|
2915
|
+
function isText(node) {
|
|
2916
|
+
return node.type === ElementType.Text;
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* Checks if `node` is a comment node.
|
|
2920
|
+
* @param node Node to check.
|
|
2921
|
+
* @returns `true` if the node is a comment node.
|
|
2922
|
+
*/
|
|
2923
|
+
function isComment(node) {
|
|
2924
|
+
return node.type === ElementType.Comment;
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* Checks if `node` is a directive node.
|
|
2928
|
+
* @param node Node to check.
|
|
2929
|
+
* @returns `true` if the node is a directive node.
|
|
2930
|
+
*/
|
|
2931
|
+
function isDirective(node) {
|
|
2932
|
+
return node.type === ElementType.Directive;
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Checks if `node` is a document node.
|
|
2936
|
+
* @param node Node to check.
|
|
2937
|
+
* @returns `true` if the node is a document node.
|
|
2938
|
+
*/
|
|
2939
|
+
function isDocument(node) {
|
|
2940
|
+
return node.type === ElementType.Root;
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2943
|
+
* Checks if `node` has children.
|
|
2944
|
+
* @param node Node to check.
|
|
2945
|
+
* @returns `true` if the node has children.
|
|
2946
|
+
*/
|
|
2947
|
+
function hasChildren(node) {
|
|
2948
|
+
return Object.hasOwn(node, "children");
|
|
2949
|
+
}
|
|
2950
|
+
/**
|
|
2951
|
+
* Clone a node, and optionally its children.
|
|
2952
|
+
* @param node Node to clone.
|
|
2953
|
+
* @param recursive Clone child nodes as well.
|
|
2954
|
+
* @returns A clone of the node.
|
|
2955
|
+
*/
|
|
2956
|
+
function cloneNode(node, recursive = false) {
|
|
2957
|
+
let result;
|
|
2958
|
+
if (isText(node)) {
|
|
2959
|
+
result = new Text(node.data);
|
|
2960
|
+
}
|
|
2961
|
+
else if (isComment(node)) {
|
|
2962
|
+
result = new Comment(node.data);
|
|
2963
|
+
}
|
|
2964
|
+
else if (isTag(node)) {
|
|
2965
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
2966
|
+
const clone = new Element(node.name, { ...node.attribs }, children);
|
|
2967
|
+
for (const child of children) {
|
|
2968
|
+
child.parent = clone;
|
|
2969
|
+
}
|
|
2970
|
+
if (node.namespace != null) {
|
|
2971
|
+
clone.namespace = node.namespace;
|
|
2972
|
+
}
|
|
2973
|
+
if (node["x-attribsNamespace"]) {
|
|
2974
|
+
clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
|
|
2975
|
+
}
|
|
2976
|
+
if (node["x-attribsPrefix"]) {
|
|
2977
|
+
clone["x-attribsPrefix"] = { ...node["x-attribsPrefix"] };
|
|
2978
|
+
}
|
|
2979
|
+
result = clone;
|
|
2980
|
+
}
|
|
2981
|
+
else if (isCDATA(node)) {
|
|
2982
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
2983
|
+
const clone = new CDATA(children);
|
|
2984
|
+
for (const child of children) {
|
|
2985
|
+
child.parent = clone;
|
|
2986
|
+
}
|
|
2987
|
+
result = clone;
|
|
2988
|
+
}
|
|
2989
|
+
else if (isDocument(node)) {
|
|
2990
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
2991
|
+
const clone = new Document(children);
|
|
2992
|
+
for (const child of children) {
|
|
2993
|
+
child.parent = clone;
|
|
2994
|
+
}
|
|
2995
|
+
if (node["x-mode"]) {
|
|
2996
|
+
clone["x-mode"] = node["x-mode"];
|
|
2997
|
+
}
|
|
2998
|
+
result = clone;
|
|
2999
|
+
}
|
|
3000
|
+
else if (isDirective(node)) {
|
|
3001
|
+
const instruction = new ProcessingInstruction(node.name, node.data);
|
|
3002
|
+
if (node["x-name"] != null) {
|
|
3003
|
+
instruction["x-name"] = node["x-name"];
|
|
3004
|
+
instruction["x-publicId"] = node["x-publicId"];
|
|
3005
|
+
instruction["x-systemId"] = node["x-systemId"];
|
|
3006
|
+
}
|
|
3007
|
+
result = instruction;
|
|
3008
|
+
}
|
|
3009
|
+
else {
|
|
3010
|
+
throw new Error(`Not implemented yet: ${node.type}`);
|
|
3011
|
+
}
|
|
3012
|
+
result.startIndex = node.startIndex;
|
|
3013
|
+
result.endIndex = node.endIndex;
|
|
3014
|
+
if (node.sourceCodeLocation != null) {
|
|
3015
|
+
result.sourceCodeLocation = node.sourceCodeLocation;
|
|
3016
|
+
}
|
|
3017
|
+
return result;
|
|
2512
3018
|
}
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
exports$1.isCustomComponent = isCustomComponent;
|
|
2526
|
-
exports$1.setStyleProp = setStyleProp;
|
|
2527
|
-
const react_1 = require$$0;
|
|
2528
|
-
const style_to_js_1 = __importDefault(requireCjs());
|
|
2529
|
-
const RESERVED_SVG_MATHML_ELEMENTS = new Set([
|
|
2530
|
-
'annotation-xml',
|
|
2531
|
-
'color-profile',
|
|
2532
|
-
'font-face',
|
|
2533
|
-
'font-face-src',
|
|
2534
|
-
'font-face-uri',
|
|
2535
|
-
'font-face-format',
|
|
2536
|
-
'font-face-name',
|
|
2537
|
-
'missing-glyph',
|
|
2538
|
-
]);
|
|
2539
|
-
/**
|
|
2540
|
-
* Check if a tag is a custom component.
|
|
2541
|
-
*
|
|
2542
|
-
* @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
|
|
2543
|
-
*
|
|
2544
|
-
* @param tagName - Tag name.
|
|
2545
|
-
* @param props - Props passed to the element.
|
|
2546
|
-
* @returns - Whether the tag is custom component.
|
|
2547
|
-
*/
|
|
2548
|
-
function isCustomComponent(tagName, props) {
|
|
2549
|
-
if (!tagName.includes('-')) {
|
|
2550
|
-
return Boolean(props && typeof props.is === 'string');
|
|
2551
|
-
}
|
|
2552
|
-
// These are reserved SVG and MathML elements.
|
|
2553
|
-
// We don't mind this whitelist too much because we expect it to never grow.
|
|
2554
|
-
// The alternative is to track the namespace in a few places which is convoluted.
|
|
2555
|
-
// https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
|
|
2556
|
-
if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) {
|
|
2557
|
-
return false;
|
|
2558
|
-
}
|
|
2559
|
-
return true;
|
|
2560
|
-
}
|
|
2561
|
-
const styleOptions = {
|
|
2562
|
-
reactCompat: true,
|
|
2563
|
-
};
|
|
2564
|
-
/**
|
|
2565
|
-
* Sets style prop.
|
|
2566
|
-
*
|
|
2567
|
-
* @param style - Inline style.
|
|
2568
|
-
* @param props - Props object.
|
|
2569
|
-
*/
|
|
2570
|
-
function setStyleProp(style, props) {
|
|
2571
|
-
if (typeof style !== 'string') {
|
|
2572
|
-
return;
|
|
2573
|
-
}
|
|
2574
|
-
if (!style.trim()) {
|
|
2575
|
-
props.style = {};
|
|
2576
|
-
return;
|
|
2577
|
-
}
|
|
2578
|
-
try {
|
|
2579
|
-
props.style = (0, style_to_js_1.default)(style, styleOptions);
|
|
2580
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2581
|
-
}
|
|
2582
|
-
catch (error) {
|
|
2583
|
-
props.style = {};
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2586
|
-
/**
|
|
2587
|
-
* @see https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html
|
|
2588
|
-
*/
|
|
2589
|
-
exports$1.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
|
|
2590
|
-
/**
|
|
2591
|
-
* @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
|
|
2592
|
-
*/
|
|
2593
|
-
exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
2594
|
-
'tr',
|
|
2595
|
-
'tbody',
|
|
2596
|
-
'thead',
|
|
2597
|
-
'tfoot',
|
|
2598
|
-
'colgroup',
|
|
2599
|
-
'table',
|
|
2600
|
-
'head',
|
|
2601
|
-
'html',
|
|
2602
|
-
'frameset',
|
|
2603
|
-
]);
|
|
2604
|
-
/**
|
|
2605
|
-
* Checks if the given node can contain text nodes
|
|
2606
|
-
*
|
|
2607
|
-
* @param node - Element node.
|
|
2608
|
-
* @returns - Whether the node can contain text nodes.
|
|
2609
|
-
*/
|
|
2610
|
-
const canTextBeChildOfNode = (node) => !exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2611
|
-
exports$1.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2612
|
-
/**
|
|
2613
|
-
* Returns the first argument as is.
|
|
2614
|
-
*
|
|
2615
|
-
* @param arg - The argument to be returned.
|
|
2616
|
-
* @returns - The input argument `arg`.
|
|
2617
|
-
*/
|
|
2618
|
-
const returnFirstArg = (arg) => arg;
|
|
2619
|
-
exports$1.returnFirstArg = returnFirstArg;
|
|
2620
|
-
|
|
2621
|
-
} (utilities$1));
|
|
2622
|
-
return utilities$1;
|
|
3019
|
+
/**
|
|
3020
|
+
* Clone a list of child nodes.
|
|
3021
|
+
* @param childs The child nodes to clone.
|
|
3022
|
+
* @returns A list of cloned child nodes.
|
|
3023
|
+
*/
|
|
3024
|
+
function cloneChildren(childs) {
|
|
3025
|
+
const children = childs.map((child) => cloneNode(child, true));
|
|
3026
|
+
for (let index = 1; index < children.length; index++) {
|
|
3027
|
+
children[index].prev = children[index - 1];
|
|
3028
|
+
children[index - 1].next = children[index];
|
|
3029
|
+
}
|
|
3030
|
+
return children;
|
|
2623
3031
|
}
|
|
2624
3032
|
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
3033
|
+
// Default options
|
|
3034
|
+
const defaultOptions = {
|
|
3035
|
+
withStartIndices: false,
|
|
3036
|
+
withEndIndices: false,
|
|
3037
|
+
xmlMode: false,
|
|
3038
|
+
};
|
|
3039
|
+
/**
|
|
3040
|
+
* Event-based handler that builds a DOM tree from parser callbacks.
|
|
3041
|
+
*/
|
|
3042
|
+
class DomHandler {
|
|
3043
|
+
/** The elements of the DOM */
|
|
3044
|
+
dom = [];
|
|
3045
|
+
/** The root element for the DOM */
|
|
3046
|
+
root = new Document(this.dom);
|
|
3047
|
+
/** Called once parsing has completed. */
|
|
3048
|
+
callback;
|
|
3049
|
+
/** Settings for the handler. */
|
|
3050
|
+
options;
|
|
3051
|
+
/** Callback whenever a tag is closed. */
|
|
3052
|
+
elementCB;
|
|
3053
|
+
/** Indicated whether parsing has been completed. */
|
|
3054
|
+
done = false;
|
|
3055
|
+
/** Stack of open tags. */
|
|
3056
|
+
tagStack = [this.root];
|
|
3057
|
+
/** A data node that is still being written to. */
|
|
3058
|
+
lastNode = null;
|
|
3059
|
+
/** Reference to the parser instance. Used for location information. */
|
|
3060
|
+
parser = null;
|
|
3061
|
+
/**
|
|
3062
|
+
* @param callback Called once parsing has completed.
|
|
3063
|
+
* @param options Settings for the handler.
|
|
3064
|
+
* @param elementCB Callback whenever a tag is closed.
|
|
3065
|
+
*/
|
|
3066
|
+
constructor(callback, options, elementCB) {
|
|
3067
|
+
// Make it possible to skip arguments, for backwards-compatibility
|
|
3068
|
+
if (typeof options === "function") {
|
|
3069
|
+
elementCB = options;
|
|
3070
|
+
options = defaultOptions;
|
|
3071
|
+
}
|
|
3072
|
+
if (typeof callback === "object") {
|
|
3073
|
+
options = callback;
|
|
3074
|
+
callback = undefined;
|
|
3075
|
+
}
|
|
3076
|
+
this.callback = callback ?? null;
|
|
3077
|
+
this.options = options ?? defaultOptions;
|
|
3078
|
+
this.elementCB = elementCB ?? null;
|
|
3079
|
+
}
|
|
3080
|
+
onparserinit(parser) {
|
|
3081
|
+
this.parser = parser;
|
|
3082
|
+
}
|
|
3083
|
+
// Resets the handler back to starting state
|
|
3084
|
+
onreset() {
|
|
3085
|
+
this.dom = [];
|
|
3086
|
+
this.root = new Document(this.dom);
|
|
3087
|
+
this.done = false;
|
|
3088
|
+
this.tagStack = [this.root];
|
|
3089
|
+
this.lastNode = null;
|
|
3090
|
+
this.parser = null;
|
|
3091
|
+
}
|
|
3092
|
+
// Signals the handler that parsing is done
|
|
3093
|
+
onend() {
|
|
3094
|
+
if (this.done)
|
|
3095
|
+
return;
|
|
3096
|
+
this.done = true;
|
|
3097
|
+
this.parser = null;
|
|
3098
|
+
this.handleCallback(null);
|
|
3099
|
+
}
|
|
3100
|
+
onerror(error) {
|
|
3101
|
+
this.handleCallback(error);
|
|
3102
|
+
}
|
|
3103
|
+
onclosetag() {
|
|
3104
|
+
this.lastNode = null;
|
|
3105
|
+
const element = this.tagStack.pop();
|
|
3106
|
+
if (this.options.withEndIndices && this.parser) {
|
|
3107
|
+
element.endIndex = this.parser.endIndex;
|
|
3108
|
+
}
|
|
3109
|
+
if (this.elementCB)
|
|
3110
|
+
this.elementCB(element);
|
|
3111
|
+
}
|
|
3112
|
+
onopentag(name, attribs) {
|
|
3113
|
+
const type = this.options.xmlMode ? ElementType.Tag : undefined;
|
|
3114
|
+
const element = new Element(name, attribs, undefined, type);
|
|
3115
|
+
this.addNode(element);
|
|
3116
|
+
this.tagStack.push(element);
|
|
3117
|
+
}
|
|
3118
|
+
ontext(data) {
|
|
3119
|
+
const { lastNode } = this;
|
|
3120
|
+
if (lastNode && lastNode.type === ElementType.Text) {
|
|
3121
|
+
lastNode.data += data;
|
|
3122
|
+
if (this.options.withEndIndices && this.parser) {
|
|
3123
|
+
lastNode.endIndex = this.parser.endIndex;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
else {
|
|
3127
|
+
const node = new Text(data);
|
|
3128
|
+
this.addNode(node);
|
|
3129
|
+
this.lastNode = node;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
oncomment(data) {
|
|
3133
|
+
if (this.lastNode && this.lastNode.type === ElementType.Comment) {
|
|
3134
|
+
this.lastNode.data += data;
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
const node = new Comment(data);
|
|
3138
|
+
this.addNode(node);
|
|
3139
|
+
this.lastNode = node;
|
|
3140
|
+
}
|
|
3141
|
+
oncommentend() {
|
|
3142
|
+
this.lastNode = null;
|
|
3143
|
+
}
|
|
3144
|
+
oncdatastart() {
|
|
3145
|
+
const text = new Text("");
|
|
3146
|
+
const node = new CDATA([text]);
|
|
3147
|
+
this.addNode(node);
|
|
3148
|
+
text.parent = node;
|
|
3149
|
+
this.lastNode = text;
|
|
3150
|
+
}
|
|
3151
|
+
oncdataend() {
|
|
3152
|
+
this.lastNode = null;
|
|
3153
|
+
}
|
|
3154
|
+
onprocessinginstruction(name, data) {
|
|
3155
|
+
const node = new ProcessingInstruction(name, data);
|
|
3156
|
+
this.addNode(node);
|
|
3157
|
+
}
|
|
3158
|
+
handleCallback(error) {
|
|
3159
|
+
if (typeof this.callback === "function") {
|
|
3160
|
+
this.callback(error, this.dom);
|
|
3161
|
+
}
|
|
3162
|
+
else if (error) {
|
|
3163
|
+
throw error;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
addNode(node) {
|
|
3167
|
+
const parent = this.tagStack[this.tagStack.length - 1];
|
|
3168
|
+
const previousSibling = parent.children[parent.children.length - 1];
|
|
3169
|
+
if (this.options.withStartIndices && this.parser) {
|
|
3170
|
+
node.startIndex = this.parser.startIndex;
|
|
3171
|
+
}
|
|
3172
|
+
if (this.options.withEndIndices && this.parser) {
|
|
3173
|
+
node.endIndex = this.parser.endIndex;
|
|
3174
|
+
}
|
|
3175
|
+
parent.children.push(node);
|
|
3176
|
+
if (previousSibling) {
|
|
3177
|
+
node.prev = previousSibling;
|
|
3178
|
+
previousSibling.next = node;
|
|
3179
|
+
}
|
|
3180
|
+
node.parent = parent;
|
|
3181
|
+
this.lastNode = null;
|
|
3182
|
+
}
|
|
2703
3183
|
}
|
|
2704
3184
|
|
|
2705
|
-
var
|
|
2706
|
-
|
|
2707
|
-
|
|
3185
|
+
var dist = /*#__PURE__*/Object.freeze({
|
|
3186
|
+
__proto__: null,
|
|
3187
|
+
CDATA: CDATA,
|
|
3188
|
+
Comment: Comment,
|
|
3189
|
+
DataNode: DataNode,
|
|
3190
|
+
Document: Document,
|
|
3191
|
+
DomHandler: DomHandler,
|
|
3192
|
+
Element: Element,
|
|
3193
|
+
Node: Node,
|
|
3194
|
+
NodeWithChildren: NodeWithChildren,
|
|
3195
|
+
ProcessingInstruction: ProcessingInstruction,
|
|
3196
|
+
Text: Text,
|
|
3197
|
+
cloneNode: cloneNode,
|
|
3198
|
+
default: DomHandler,
|
|
3199
|
+
hasChildren: hasChildren,
|
|
3200
|
+
isCDATA: isCDATA,
|
|
3201
|
+
isComment: isComment,
|
|
3202
|
+
isDirective: isDirective,
|
|
3203
|
+
isDocument: isDocument,
|
|
3204
|
+
isTag: isTag,
|
|
3205
|
+
isText: isText
|
|
3206
|
+
});
|
|
2708
3207
|
|
|
2709
|
-
|
|
2710
|
-
if (hasRequiredDomToReact) return domToReact;
|
|
2711
|
-
hasRequiredDomToReact = 1;
|
|
2712
|
-
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
|
|
2713
|
-
var __importDefault = (domToReact && domToReact.__importDefault) || function (mod) {
|
|
2714
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2715
|
-
};
|
|
2716
|
-
Object.defineProperty(domToReact, "__esModule", { value: true });
|
|
2717
|
-
domToReact.default = domToReact$1;
|
|
2718
|
-
const react_1 = require$$0;
|
|
2719
|
-
const attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
2720
|
-
const utilities_1 = requireUtilities();
|
|
2721
|
-
const React = {
|
|
2722
|
-
cloneElement: react_1.cloneElement,
|
|
2723
|
-
createElement: react_1.createElement,
|
|
2724
|
-
isValidElement: react_1.isValidElement,
|
|
2725
|
-
};
|
|
2726
|
-
/**
|
|
2727
|
-
* Converts DOM nodes to JSX element(s).
|
|
2728
|
-
*
|
|
2729
|
-
* @param nodes - DOM nodes.
|
|
2730
|
-
* @param options - Options.
|
|
2731
|
-
* @returns - String or JSX element(s).
|
|
2732
|
-
*/
|
|
2733
|
-
function domToReact$1(nodes, options = {}) {
|
|
2734
|
-
var _a, _b, _c, _d, _e;
|
|
2735
|
-
const reactElements = [];
|
|
2736
|
-
const hasReplace = typeof options.replace === 'function';
|
|
2737
|
-
const transform = (_a = options.transform) !== null && _a !== void 0 ? _a : utilities_1.returnFirstArg;
|
|
2738
|
-
const { cloneElement, createElement, isValidElement } = (_b = options.library) !== null && _b !== void 0 ? _b : React;
|
|
2739
|
-
const nodesLength = nodes.length;
|
|
2740
|
-
for (let index = 0; index < nodesLength; index++) {
|
|
2741
|
-
const node = nodes[index];
|
|
2742
|
-
// replace with custom React element (if present)
|
|
2743
|
-
if (hasReplace) {
|
|
2744
|
-
let replaceElement = (_c = options.replace) === null || _c === void 0 ? void 0 : _c.call(options, node, index);
|
|
2745
|
-
if (isValidElement(replaceElement)) {
|
|
2746
|
-
// set "key" prop for sibling elements
|
|
2747
|
-
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
2748
|
-
if (nodesLength > 1) {
|
|
2749
|
-
replaceElement = cloneElement(replaceElement, {
|
|
2750
|
-
key: (_d = replaceElement.key) !== null && _d !== void 0 ? _d : index,
|
|
2751
|
-
});
|
|
2752
|
-
}
|
|
2753
|
-
reactElements.push(transform(replaceElement, node, index));
|
|
2754
|
-
continue;
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
if (node.type === 'text') {
|
|
2758
|
-
const isWhitespace = !node.data.trim().length;
|
|
2759
|
-
// We have a whitespace node that can't be nested in its parent
|
|
2760
|
-
// so skip it
|
|
2761
|
-
if (isWhitespace &&
|
|
2762
|
-
node.parent &&
|
|
2763
|
-
!(0, utilities_1.canTextBeChildOfNode)(node.parent)) {
|
|
2764
|
-
continue;
|
|
2765
|
-
}
|
|
2766
|
-
// Trim is enabled and we have a whitespace node
|
|
2767
|
-
// so skip it
|
|
2768
|
-
if (options.trim && isWhitespace) {
|
|
2769
|
-
continue;
|
|
2770
|
-
}
|
|
2771
|
-
// We have a text node that's not whitespace and it can be nested
|
|
2772
|
-
// in its parent so add it to the results
|
|
2773
|
-
reactElements.push(transform(node.data, node, index));
|
|
2774
|
-
continue;
|
|
2775
|
-
}
|
|
2776
|
-
const element = node;
|
|
2777
|
-
let props = {};
|
|
2778
|
-
if (skipAttributesToProps(element)) {
|
|
2779
|
-
(0, utilities_1.setStyleProp)(element.attribs.style, element.attribs);
|
|
2780
|
-
props = element.attribs;
|
|
2781
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2782
|
-
}
|
|
2783
|
-
else if (element.attribs) {
|
|
2784
|
-
props = (0, attributes_to_props_1.default)(element.attribs, element.name);
|
|
2785
|
-
}
|
|
2786
|
-
let children;
|
|
2787
|
-
switch (node.type) {
|
|
2788
|
-
case 'script':
|
|
2789
|
-
case 'style':
|
|
2790
|
-
// prevent text in <script> or <style> from being escaped
|
|
2791
|
-
// https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html
|
|
2792
|
-
if (node.children[0]) {
|
|
2793
|
-
props.dangerouslySetInnerHTML = {
|
|
2794
|
-
__html: node.children[0].data,
|
|
2795
|
-
};
|
|
2796
|
-
}
|
|
2797
|
-
break;
|
|
2798
|
-
case 'tag':
|
|
2799
|
-
// setting textarea value in children is an antipattern in React
|
|
2800
|
-
// https://react.dev/reference/react-dom/components/textarea#caveats
|
|
2801
|
-
if (node.name === 'textarea' && node.children[0]) {
|
|
2802
|
-
props.defaultValue = node.children[0].data;
|
|
2803
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
2804
|
-
}
|
|
2805
|
-
else if ((_e = node.children) === null || _e === void 0 ? void 0 : _e.length) {
|
|
2806
|
-
// continue recursion of creating React elements (if applicable)
|
|
2807
|
-
children = domToReact$1(node.children, options);
|
|
2808
|
-
}
|
|
2809
|
-
break;
|
|
2810
|
-
// skip all other cases (e.g., comment)
|
|
2811
|
-
default:
|
|
2812
|
-
continue;
|
|
2813
|
-
}
|
|
2814
|
-
// set "key" prop for sibling elements
|
|
2815
|
-
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
2816
|
-
if (nodesLength > 1) {
|
|
2817
|
-
props.key = index;
|
|
2818
|
-
}
|
|
2819
|
-
reactElements.push(transform(createElement(node.name, props, children), node, index));
|
|
2820
|
-
}
|
|
2821
|
-
return reactElements.length === 1 ? reactElements[0] : reactElements;
|
|
2822
|
-
}
|
|
2823
|
-
/**
|
|
2824
|
-
* Determines whether DOM element attributes should be transformed to props.
|
|
2825
|
-
* Web Components should not have their attributes transformed except for `style`.
|
|
2826
|
-
*
|
|
2827
|
-
* @param node - Element node.
|
|
2828
|
-
* @returns - Whether the node attributes should be converted to props.
|
|
2829
|
-
*/
|
|
2830
|
-
function skipAttributesToProps(node) {
|
|
2831
|
-
return (utilities_1.PRESERVE_CUSTOM_ATTRIBUTES &&
|
|
2832
|
-
node.type === 'tag' &&
|
|
2833
|
-
(0, utilities_1.isCustomComponent)(node.name, node.attribs));
|
|
2834
|
-
}
|
|
2835
|
-
|
|
2836
|
-
return domToReact;
|
|
2837
|
-
}
|
|
3208
|
+
var require$$3 = /*@__PURE__*/getAugmentedNamespace(dist);
|
|
2838
3209
|
|
|
2839
3210
|
var hasRequiredLib;
|
|
2840
3211
|
|
|
2841
3212
|
function requireLib () {
|
|
2842
3213
|
if (hasRequiredLib) return lib$1;
|
|
2843
3214
|
hasRequiredLib = 1;
|
|
2844
|
-
(function (exports
|
|
3215
|
+
(function (exports) {
|
|
2845
3216
|
var __importDefault = (lib$1 && lib$1.__importDefault) || function (mod) {
|
|
2846
3217
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2847
3218
|
};
|
|
2848
|
-
Object.defineProperty(exports
|
|
2849
|
-
exports
|
|
2850
|
-
exports
|
|
3219
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3220
|
+
exports.htmlToDOM = exports.domToReact = exports.attributesToProps = exports.Text = exports.ProcessingInstruction = exports.Element = exports.Comment = void 0;
|
|
3221
|
+
exports.default = HTMLReactParser;
|
|
2851
3222
|
const html_dom_parser_1 = __importDefault(requireHtmlToDom());
|
|
2852
|
-
exports
|
|
3223
|
+
exports.htmlToDOM = html_dom_parser_1.default;
|
|
2853
3224
|
const attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
2854
|
-
exports
|
|
3225
|
+
exports.attributesToProps = attributes_to_props_1.default;
|
|
2855
3226
|
const dom_to_react_1 = __importDefault(requireDomToReact());
|
|
2856
|
-
exports
|
|
3227
|
+
exports.domToReact = dom_to_react_1.default;
|
|
2857
3228
|
var domhandler_1 = require$$3;
|
|
2858
|
-
Object.defineProperty(exports
|
|
2859
|
-
Object.defineProperty(exports
|
|
2860
|
-
Object.defineProperty(exports
|
|
2861
|
-
Object.defineProperty(exports
|
|
3229
|
+
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
|
|
3230
|
+
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
|
|
3231
|
+
Object.defineProperty(exports, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
|
|
3232
|
+
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return domhandler_1.Text; } });
|
|
2862
3233
|
const domParserOptions = { lowerCaseAttributeNames: false };
|
|
2863
3234
|
/**
|
|
2864
3235
|
* Converts HTML string to React elements.
|
|
@@ -2875,7 +3246,8 @@
|
|
|
2875
3246
|
if (!html) {
|
|
2876
3247
|
return [];
|
|
2877
3248
|
}
|
|
2878
|
-
|
|
3249
|
+
const htmlToDOMOptions = Object.assign(Object.assign({}, ((_a = options === null || options === void 0 ? void 0 : options.htmlparser2) !== null && _a !== void 0 ? _a : domParserOptions)), { trustedTypePolicy: options === null || options === void 0 ? void 0 : options.trustedTypePolicy });
|
|
3250
|
+
return (0, dom_to_react_1.default)((0, html_dom_parser_1.default)(html, htmlToDOMOptions), options);
|
|
2879
3251
|
}
|
|
2880
3252
|
|
|
2881
3253
|
} (lib$1));
|