html-react-parser 5.2.17 → 6.0.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/dist/html-react-parser.js +683 -794
- 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/attributes-to-props.js +13 -14
- package/lib/attributes-to-props.js.map +1 -1
- package/lib/dom-to-react.js +17 -18
- package/lib/dom-to-react.js.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/utilities.d.ts +1 -1
- package/lib/utilities.js +6 -8
- package/lib/utilities.js.map +1 -1
- package/package.json +28 -28
|
@@ -23,7 +23,36 @@
|
|
|
23
23
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
function getAugmentedNamespace(n) {
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
28
|
+
var f = n.default;
|
|
29
|
+
if (typeof f == "function") {
|
|
30
|
+
var a = function a () {
|
|
31
|
+
var isInstance = false;
|
|
32
|
+
try {
|
|
33
|
+
isInstance = this instanceof a;
|
|
34
|
+
} catch {}
|
|
35
|
+
if (isInstance) {
|
|
36
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
37
|
+
}
|
|
38
|
+
return f.apply(this, arguments);
|
|
39
|
+
};
|
|
40
|
+
a.prototype = f.prototype;
|
|
41
|
+
} else a = {};
|
|
42
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
43
|
+
Object.keys(n).forEach(function (k) {
|
|
44
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
45
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return n[k];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return a;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var lib$1 = {};
|
|
27
56
|
|
|
28
57
|
var htmlToDom = {};
|
|
29
58
|
|
|
@@ -31,731 +60,603 @@
|
|
|
31
60
|
|
|
32
61
|
var utilities$2 = {};
|
|
33
62
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/** Type for <!doctype ...> */
|
|
66
|
-
ElementType["Doctype"] = "doctype";
|
|
67
|
-
})(ElementType = exports$1.ElementType || (exports$1.ElementType = {}));
|
|
68
|
-
/**
|
|
69
|
-
* Tests whether an element is a tag or not.
|
|
70
|
-
*
|
|
71
|
-
* @param elem Element to test
|
|
72
|
-
*/
|
|
73
|
-
function isTag(elem) {
|
|
74
|
-
return (elem.type === ElementType.Tag ||
|
|
75
|
-
elem.type === ElementType.Script ||
|
|
76
|
-
elem.type === ElementType.Style);
|
|
77
|
-
}
|
|
78
|
-
exports$1.isTag = isTag;
|
|
79
|
-
// Exports for backwards compatibility
|
|
80
|
-
/** Type for the root element of a document */
|
|
81
|
-
exports$1.Root = ElementType.Root;
|
|
82
|
-
/** Type for Text */
|
|
83
|
-
exports$1.Text = ElementType.Text;
|
|
84
|
-
/** Type for <? ... ?> */
|
|
85
|
-
exports$1.Directive = ElementType.Directive;
|
|
86
|
-
/** Type for <!-- ... --> */
|
|
87
|
-
exports$1.Comment = ElementType.Comment;
|
|
88
|
-
/** Type for <script> tags */
|
|
89
|
-
exports$1.Script = ElementType.Script;
|
|
90
|
-
/** Type for <style> tags */
|
|
91
|
-
exports$1.Style = ElementType.Style;
|
|
92
|
-
/** Type for Any tag */
|
|
93
|
-
exports$1.Tag = ElementType.Tag;
|
|
94
|
-
/** Type for <![CDATA[ ... ]]> */
|
|
95
|
-
exports$1.CDATA = ElementType.CDATA;
|
|
96
|
-
/** Type for <!doctype ...> */
|
|
97
|
-
exports$1.Doctype = ElementType.Doctype;
|
|
98
|
-
} (lib$1));
|
|
99
|
-
return lib$1;
|
|
63
|
+
/** Types of elements found in htmlparser2's DOM */
|
|
64
|
+
var ElementType;
|
|
65
|
+
(function (ElementType) {
|
|
66
|
+
/** Type for the root element of a document */
|
|
67
|
+
ElementType["Root"] = "root";
|
|
68
|
+
/** Type for Text */
|
|
69
|
+
ElementType["Text"] = "text";
|
|
70
|
+
/** Type for <? ... ?> */
|
|
71
|
+
ElementType["Directive"] = "directive";
|
|
72
|
+
/** Type for <!-- ... --> */
|
|
73
|
+
ElementType["Comment"] = "comment";
|
|
74
|
+
/** Type for <script> tags */
|
|
75
|
+
ElementType["Script"] = "script";
|
|
76
|
+
/** Type for <style> tags */
|
|
77
|
+
ElementType["Style"] = "style";
|
|
78
|
+
/** Type for Any tag */
|
|
79
|
+
ElementType["Tag"] = "tag";
|
|
80
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
81
|
+
ElementType["CDATA"] = "cdata";
|
|
82
|
+
/** Type for <!doctype ...> */
|
|
83
|
+
ElementType["Doctype"] = "doctype";
|
|
84
|
+
})(ElementType || (ElementType = {}));
|
|
85
|
+
/**
|
|
86
|
+
* Tests whether an element is a tag or not.
|
|
87
|
+
* @param element Element to test
|
|
88
|
+
* @param element.type Node type discriminator to check.
|
|
89
|
+
*/
|
|
90
|
+
function isTag$1(element) {
|
|
91
|
+
return (element.type === ElementType.Tag ||
|
|
92
|
+
element.type === ElementType.Script ||
|
|
93
|
+
element.type === ElementType.Style);
|
|
100
94
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
488
|
-
*/
|
|
489
|
-
function isDirective(node) {
|
|
490
|
-
return node.type === domelementtype_1.ElementType.Directive;
|
|
491
|
-
}
|
|
492
|
-
node.isDirective = isDirective;
|
|
493
|
-
/**
|
|
494
|
-
* @param node Node to check.
|
|
495
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
496
|
-
*/
|
|
497
|
-
function isDocument(node) {
|
|
498
|
-
return node.type === domelementtype_1.ElementType.Root;
|
|
499
|
-
}
|
|
500
|
-
node.isDocument = isDocument;
|
|
501
|
-
/**
|
|
502
|
-
* @param node Node to check.
|
|
503
|
-
* @returns `true` if the node has children, `false` otherwise.
|
|
504
|
-
*/
|
|
505
|
-
function hasChildren(node) {
|
|
506
|
-
return Object.prototype.hasOwnProperty.call(node, "children");
|
|
507
|
-
}
|
|
508
|
-
node.hasChildren = hasChildren;
|
|
509
|
-
/**
|
|
510
|
-
* Clone a node, and optionally its children.
|
|
511
|
-
*
|
|
512
|
-
* @param recursive Clone child nodes as well.
|
|
513
|
-
* @returns A clone of the node.
|
|
514
|
-
*/
|
|
515
|
-
function cloneNode(node, recursive) {
|
|
516
|
-
if (recursive === void 0) { recursive = false; }
|
|
517
|
-
var result;
|
|
518
|
-
if (isText(node)) {
|
|
519
|
-
result = new Text(node.data);
|
|
520
|
-
}
|
|
521
|
-
else if (isComment(node)) {
|
|
522
|
-
result = new Comment(node.data);
|
|
523
|
-
}
|
|
524
|
-
else if (isTag(node)) {
|
|
525
|
-
var children = recursive ? cloneChildren(node.children) : [];
|
|
526
|
-
var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
|
|
527
|
-
children.forEach(function (child) { return (child.parent = clone_1); });
|
|
528
|
-
if (node.namespace != null) {
|
|
529
|
-
clone_1.namespace = node.namespace;
|
|
530
|
-
}
|
|
531
|
-
if (node["x-attribsNamespace"]) {
|
|
532
|
-
clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
|
|
533
|
-
}
|
|
534
|
-
if (node["x-attribsPrefix"]) {
|
|
535
|
-
clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
|
|
536
|
-
}
|
|
537
|
-
result = clone_1;
|
|
538
|
-
}
|
|
539
|
-
else if (isCDATA(node)) {
|
|
540
|
-
var children = recursive ? cloneChildren(node.children) : [];
|
|
541
|
-
var clone_2 = new CDATA(children);
|
|
542
|
-
children.forEach(function (child) { return (child.parent = clone_2); });
|
|
543
|
-
result = clone_2;
|
|
544
|
-
}
|
|
545
|
-
else if (isDocument(node)) {
|
|
546
|
-
var children = recursive ? cloneChildren(node.children) : [];
|
|
547
|
-
var clone_3 = new Document(children);
|
|
548
|
-
children.forEach(function (child) { return (child.parent = clone_3); });
|
|
549
|
-
if (node["x-mode"]) {
|
|
550
|
-
clone_3["x-mode"] = node["x-mode"];
|
|
551
|
-
}
|
|
552
|
-
result = clone_3;
|
|
553
|
-
}
|
|
554
|
-
else if (isDirective(node)) {
|
|
555
|
-
var instruction = new ProcessingInstruction(node.name, node.data);
|
|
556
|
-
if (node["x-name"] != null) {
|
|
557
|
-
instruction["x-name"] = node["x-name"];
|
|
558
|
-
instruction["x-publicId"] = node["x-publicId"];
|
|
559
|
-
instruction["x-systemId"] = node["x-systemId"];
|
|
560
|
-
}
|
|
561
|
-
result = instruction;
|
|
562
|
-
}
|
|
563
|
-
else {
|
|
564
|
-
throw new Error("Not implemented yet: ".concat(node.type));
|
|
565
|
-
}
|
|
566
|
-
result.startIndex = node.startIndex;
|
|
567
|
-
result.endIndex = node.endIndex;
|
|
568
|
-
if (node.sourceCodeLocation != null) {
|
|
569
|
-
result.sourceCodeLocation = node.sourceCodeLocation;
|
|
570
|
-
}
|
|
571
|
-
return result;
|
|
572
|
-
}
|
|
573
|
-
node.cloneNode = cloneNode;
|
|
574
|
-
function cloneChildren(childs) {
|
|
575
|
-
var children = childs.map(function (child) { return cloneNode(child, true); });
|
|
576
|
-
for (var i = 1; i < children.length; i++) {
|
|
577
|
-
children[i].prev = children[i - 1];
|
|
578
|
-
children[i - 1].next = children[i];
|
|
579
|
-
}
|
|
580
|
-
return children;
|
|
581
|
-
}
|
|
582
|
-
return node;
|
|
95
|
+
// Exports for backwards compatibility
|
|
96
|
+
/** Type for the root element of a document */
|
|
97
|
+
// eslint-disable-next-line prefer-destructuring
|
|
98
|
+
ElementType.Root;
|
|
99
|
+
/** Type for Text */
|
|
100
|
+
// eslint-disable-next-line prefer-destructuring
|
|
101
|
+
ElementType.Text;
|
|
102
|
+
/** Type for <? ... ?> */
|
|
103
|
+
// eslint-disable-next-line prefer-destructuring
|
|
104
|
+
ElementType.Directive;
|
|
105
|
+
/** Type for <!-- ... --> */
|
|
106
|
+
// eslint-disable-next-line prefer-destructuring
|
|
107
|
+
ElementType.Comment;
|
|
108
|
+
/** Type for <script> tags */
|
|
109
|
+
// eslint-disable-next-line prefer-destructuring
|
|
110
|
+
ElementType.Script;
|
|
111
|
+
/** Type for <style> tags */
|
|
112
|
+
// eslint-disable-next-line prefer-destructuring
|
|
113
|
+
ElementType.Style;
|
|
114
|
+
/** Type for Any tag */
|
|
115
|
+
// eslint-disable-next-line prefer-destructuring
|
|
116
|
+
ElementType.Tag;
|
|
117
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
118
|
+
// eslint-disable-next-line prefer-destructuring
|
|
119
|
+
ElementType.CDATA;
|
|
120
|
+
/** Type for <!doctype ...> */
|
|
121
|
+
// eslint-disable-next-line prefer-destructuring
|
|
122
|
+
ElementType.Doctype;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* This object will be used as the prototype for Nodes when creating a
|
|
126
|
+
* DOM-Level-1-compliant structure.
|
|
127
|
+
*/
|
|
128
|
+
class Node {
|
|
129
|
+
/** Parent of the node */
|
|
130
|
+
parent = null;
|
|
131
|
+
/** Previous sibling */
|
|
132
|
+
prev = null;
|
|
133
|
+
/** Next sibling */
|
|
134
|
+
next = null;
|
|
135
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
136
|
+
startIndex = null;
|
|
137
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
138
|
+
endIndex = null;
|
|
139
|
+
// Read-write aliases for properties
|
|
140
|
+
/**
|
|
141
|
+
* Same as {@link parent}.
|
|
142
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
143
|
+
*/
|
|
144
|
+
get parentNode() {
|
|
145
|
+
return this.parent;
|
|
146
|
+
}
|
|
147
|
+
set parentNode(parent) {
|
|
148
|
+
this.parent = parent;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Same as {@link prev}.
|
|
152
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
153
|
+
*/
|
|
154
|
+
get previousSibling() {
|
|
155
|
+
return this.prev;
|
|
156
|
+
}
|
|
157
|
+
set previousSibling(previous) {
|
|
158
|
+
this.prev = previous;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Same as {@link next}.
|
|
162
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
163
|
+
*/
|
|
164
|
+
get nextSibling() {
|
|
165
|
+
return this.next;
|
|
166
|
+
}
|
|
167
|
+
set nextSibling(next) {
|
|
168
|
+
this.next = next;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Clone this node, and optionally its children.
|
|
172
|
+
* @param recursive Clone child nodes as well.
|
|
173
|
+
* @returns A clone of the node.
|
|
174
|
+
*/
|
|
175
|
+
cloneNode(recursive = false) {
|
|
176
|
+
return cloneNode(this, recursive);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A node that contains some data.
|
|
181
|
+
*/
|
|
182
|
+
class DataNode extends Node {
|
|
183
|
+
data;
|
|
184
|
+
/**
|
|
185
|
+
* @param data The content of the data node
|
|
186
|
+
*/
|
|
187
|
+
constructor(data) {
|
|
188
|
+
super();
|
|
189
|
+
this.data = data;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Same as {@link data}.
|
|
193
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
194
|
+
*/
|
|
195
|
+
get nodeValue() {
|
|
196
|
+
return this.data;
|
|
197
|
+
}
|
|
198
|
+
set nodeValue(data) {
|
|
199
|
+
this.data = data;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Text within the document.
|
|
204
|
+
*/
|
|
205
|
+
class Text extends DataNode {
|
|
206
|
+
type = ElementType.Text;
|
|
207
|
+
get nodeType() {
|
|
208
|
+
return 3;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Comments within the document.
|
|
213
|
+
*/
|
|
214
|
+
class Comment extends DataNode {
|
|
215
|
+
type = ElementType.Comment;
|
|
216
|
+
get nodeType() {
|
|
217
|
+
return 8;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Processing instructions, including doc types.
|
|
222
|
+
*/
|
|
223
|
+
class ProcessingInstruction extends DataNode {
|
|
224
|
+
type = ElementType.Directive;
|
|
225
|
+
name;
|
|
226
|
+
constructor(name, data) {
|
|
227
|
+
super(data);
|
|
228
|
+
this.name = name;
|
|
229
|
+
}
|
|
230
|
+
get nodeType() {
|
|
231
|
+
return 1;
|
|
232
|
+
}
|
|
233
|
+
/** If this is a doctype, the document type name (parse5 only). */
|
|
234
|
+
"x-name";
|
|
235
|
+
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
236
|
+
"x-publicId";
|
|
237
|
+
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
238
|
+
"x-systemId";
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* A node that can have children.
|
|
242
|
+
*/
|
|
243
|
+
class NodeWithChildren extends Node {
|
|
244
|
+
children;
|
|
245
|
+
/**
|
|
246
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
247
|
+
*/
|
|
248
|
+
constructor(children) {
|
|
249
|
+
super();
|
|
250
|
+
this.children = children;
|
|
251
|
+
}
|
|
252
|
+
// Aliases
|
|
253
|
+
/** First child of the node. */
|
|
254
|
+
get firstChild() {
|
|
255
|
+
return this.children[0] ?? null;
|
|
256
|
+
}
|
|
257
|
+
/** Last child of the node. */
|
|
258
|
+
get lastChild() {
|
|
259
|
+
return this.children.length > 0
|
|
260
|
+
? this.children[this.children.length - 1]
|
|
261
|
+
: null;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Same as {@link children}.
|
|
265
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
266
|
+
*/
|
|
267
|
+
get childNodes() {
|
|
268
|
+
return this.children;
|
|
269
|
+
}
|
|
270
|
+
set childNodes(children) {
|
|
271
|
+
this.children = children;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* CDATA nodes.
|
|
276
|
+
*/
|
|
277
|
+
class CDATA extends NodeWithChildren {
|
|
278
|
+
type = ElementType.CDATA;
|
|
279
|
+
get nodeType() {
|
|
280
|
+
return 4;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The root node of the document.
|
|
285
|
+
*/
|
|
286
|
+
class Document extends NodeWithChildren {
|
|
287
|
+
type = ElementType.Root;
|
|
288
|
+
get nodeType() {
|
|
289
|
+
return 9;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* An element within the DOM.
|
|
294
|
+
*/
|
|
295
|
+
class Element extends NodeWithChildren {
|
|
296
|
+
name;
|
|
297
|
+
attribs;
|
|
298
|
+
type;
|
|
299
|
+
/**
|
|
300
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
301
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
302
|
+
* @param children Children of the node.
|
|
303
|
+
* @param type Node type used for the new node instance.
|
|
304
|
+
*/
|
|
305
|
+
constructor(name, attribs, children = [], type = name === "script"
|
|
306
|
+
? ElementType.Script
|
|
307
|
+
: name === "style"
|
|
308
|
+
? ElementType.Style
|
|
309
|
+
: ElementType.Tag) {
|
|
310
|
+
super(children);
|
|
311
|
+
this.name = name;
|
|
312
|
+
this.attribs = attribs;
|
|
313
|
+
this.type = type;
|
|
314
|
+
}
|
|
315
|
+
get nodeType() {
|
|
316
|
+
return 1;
|
|
317
|
+
}
|
|
318
|
+
// DOM Level 1 aliases
|
|
319
|
+
/**
|
|
320
|
+
* Same as {@link name}.
|
|
321
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
322
|
+
*/
|
|
323
|
+
get tagName() {
|
|
324
|
+
return this.name;
|
|
325
|
+
}
|
|
326
|
+
set tagName(name) {
|
|
327
|
+
this.name = name;
|
|
328
|
+
}
|
|
329
|
+
get attributes() {
|
|
330
|
+
return Object.keys(this.attribs).map((name) => ({
|
|
331
|
+
name,
|
|
332
|
+
value: this.attribs[name],
|
|
333
|
+
namespace: this["x-attribsNamespace"]?.[name],
|
|
334
|
+
prefix: this["x-attribsPrefix"]?.[name],
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
/** Element namespace (parse5 only). */
|
|
338
|
+
namespace;
|
|
339
|
+
/** Element attribute namespaces (parse5 only). */
|
|
340
|
+
"x-attribsNamespace";
|
|
341
|
+
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
342
|
+
"x-attribsPrefix";
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Checks if `node` is an element node.
|
|
346
|
+
* @param node Node to check.
|
|
347
|
+
* @returns `true` if the node is an element node.
|
|
348
|
+
*/
|
|
349
|
+
function isTag(node) {
|
|
350
|
+
return isTag$1(node);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Checks if `node` is a CDATA node.
|
|
354
|
+
* @param node Node to check.
|
|
355
|
+
* @returns `true` if the node is a CDATA node.
|
|
356
|
+
*/
|
|
357
|
+
function isCDATA(node) {
|
|
358
|
+
return node.type === ElementType.CDATA;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Checks if `node` is a text node.
|
|
362
|
+
* @param node Node to check.
|
|
363
|
+
* @returns `true` if the node is a text node.
|
|
364
|
+
*/
|
|
365
|
+
function isText(node) {
|
|
366
|
+
return node.type === ElementType.Text;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Checks if `node` is a comment node.
|
|
370
|
+
* @param node Node to check.
|
|
371
|
+
* @returns `true` if the node is a comment node.
|
|
372
|
+
*/
|
|
373
|
+
function isComment(node) {
|
|
374
|
+
return node.type === ElementType.Comment;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Checks if `node` is a directive node.
|
|
378
|
+
* @param node Node to check.
|
|
379
|
+
* @returns `true` if the node is a directive node.
|
|
380
|
+
*/
|
|
381
|
+
function isDirective(node) {
|
|
382
|
+
return node.type === ElementType.Directive;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Checks if `node` is a document node.
|
|
386
|
+
* @param node Node to check.
|
|
387
|
+
* @returns `true` if the node is a document node.
|
|
388
|
+
*/
|
|
389
|
+
function isDocument(node) {
|
|
390
|
+
return node.type === ElementType.Root;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Checks if `node` has children.
|
|
394
|
+
* @param node Node to check.
|
|
395
|
+
* @returns `true` if the node has children.
|
|
396
|
+
*/
|
|
397
|
+
function hasChildren(node) {
|
|
398
|
+
return Object.hasOwn(node, "children");
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Clone a node, and optionally its children.
|
|
402
|
+
* @param node Node to clone.
|
|
403
|
+
* @param recursive Clone child nodes as well.
|
|
404
|
+
* @returns A clone of the node.
|
|
405
|
+
*/
|
|
406
|
+
function cloneNode(node, recursive = false) {
|
|
407
|
+
let result;
|
|
408
|
+
if (isText(node)) {
|
|
409
|
+
result = new Text(node.data);
|
|
410
|
+
}
|
|
411
|
+
else if (isComment(node)) {
|
|
412
|
+
result = new Comment(node.data);
|
|
413
|
+
}
|
|
414
|
+
else if (isTag(node)) {
|
|
415
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
416
|
+
const clone = new Element(node.name, { ...node.attribs }, children);
|
|
417
|
+
for (const child of children) {
|
|
418
|
+
child.parent = clone;
|
|
419
|
+
}
|
|
420
|
+
if (node.namespace != null) {
|
|
421
|
+
clone.namespace = node.namespace;
|
|
422
|
+
}
|
|
423
|
+
if (node["x-attribsNamespace"]) {
|
|
424
|
+
clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
|
|
425
|
+
}
|
|
426
|
+
if (node["x-attribsPrefix"]) {
|
|
427
|
+
clone["x-attribsPrefix"] = { ...node["x-attribsPrefix"] };
|
|
428
|
+
}
|
|
429
|
+
result = clone;
|
|
430
|
+
}
|
|
431
|
+
else if (isCDATA(node)) {
|
|
432
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
433
|
+
const clone = new CDATA(children);
|
|
434
|
+
for (const child of children) {
|
|
435
|
+
child.parent = clone;
|
|
436
|
+
}
|
|
437
|
+
result = clone;
|
|
438
|
+
}
|
|
439
|
+
else if (isDocument(node)) {
|
|
440
|
+
const children = recursive ? cloneChildren(node.children) : [];
|
|
441
|
+
const clone = new Document(children);
|
|
442
|
+
for (const child of children) {
|
|
443
|
+
child.parent = clone;
|
|
444
|
+
}
|
|
445
|
+
if (node["x-mode"]) {
|
|
446
|
+
clone["x-mode"] = node["x-mode"];
|
|
447
|
+
}
|
|
448
|
+
result = clone;
|
|
449
|
+
}
|
|
450
|
+
else if (isDirective(node)) {
|
|
451
|
+
const instruction = new ProcessingInstruction(node.name, node.data);
|
|
452
|
+
if (node["x-name"] != null) {
|
|
453
|
+
instruction["x-name"] = node["x-name"];
|
|
454
|
+
instruction["x-publicId"] = node["x-publicId"];
|
|
455
|
+
instruction["x-systemId"] = node["x-systemId"];
|
|
456
|
+
}
|
|
457
|
+
result = instruction;
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
throw new Error(`Not implemented yet: ${node.type}`);
|
|
461
|
+
}
|
|
462
|
+
result.startIndex = node.startIndex;
|
|
463
|
+
result.endIndex = node.endIndex;
|
|
464
|
+
if (node.sourceCodeLocation != null) {
|
|
465
|
+
result.sourceCodeLocation = node.sourceCodeLocation;
|
|
466
|
+
}
|
|
467
|
+
return result;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Clone a list of child nodes.
|
|
471
|
+
* @param childs The child nodes to clone.
|
|
472
|
+
* @returns A list of cloned child nodes.
|
|
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;
|
|
583
481
|
}
|
|
584
482
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
var parent = this.tagStack[this.tagStack.length - 1];
|
|
736
|
-
var previousSibling = parent.children[parent.children.length - 1];
|
|
737
|
-
if (this.options.withStartIndices) {
|
|
738
|
-
node.startIndex = this.parser.startIndex;
|
|
739
|
-
}
|
|
740
|
-
if (this.options.withEndIndices) {
|
|
741
|
-
node.endIndex = this.parser.endIndex;
|
|
742
|
-
}
|
|
743
|
-
parent.children.push(node);
|
|
744
|
-
if (previousSibling) {
|
|
745
|
-
node.prev = previousSibling;
|
|
746
|
-
previousSibling.next = node;
|
|
747
|
-
}
|
|
748
|
-
node.parent = parent;
|
|
749
|
-
this.lastNode = null;
|
|
750
|
-
};
|
|
751
|
-
return DomHandler;
|
|
752
|
-
}());
|
|
753
|
-
exports$1.DomHandler = DomHandler;
|
|
754
|
-
exports$1.default = DomHandler;
|
|
755
|
-
} (lib$2));
|
|
756
|
-
return lib$2;
|
|
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
|
+
}
|
|
757
633
|
}
|
|
758
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
|
+
|
|
759
660
|
var constants = {};
|
|
760
661
|
|
|
761
662
|
var hasRequiredConstants;
|
|
@@ -765,7 +666,7 @@
|
|
|
765
666
|
hasRequiredConstants = 1;
|
|
766
667
|
(function (exports$1) {
|
|
767
668
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
768
|
-
exports$1.
|
|
669
|
+
exports$1.CASE_SENSITIVE_TAG_NAMES_MAP = exports$1.CASE_SENSITIVE_TAG_NAMES = void 0;
|
|
769
670
|
/**
|
|
770
671
|
* SVG elements are case-sensitive.
|
|
771
672
|
*
|
|
@@ -808,10 +709,6 @@
|
|
|
808
709
|
accumulator[tagName.toLowerCase()] = tagName;
|
|
809
710
|
return accumulator;
|
|
810
711
|
}, {});
|
|
811
|
-
exports$1.CARRIAGE_RETURN = '\r';
|
|
812
|
-
exports$1.CARRIAGE_RETURN_REGEX = new RegExp(exports$1.CARRIAGE_RETURN, 'g');
|
|
813
|
-
exports$1.CARRIAGE_RETURN_PLACEHOLDER = "__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now().toString(), "__");
|
|
814
|
-
exports$1.CARRIAGE_RETURN_PLACEHOLDER_REGEX = new RegExp(exports$1.CARRIAGE_RETURN_PLACEHOLDER, 'g');
|
|
815
712
|
|
|
816
713
|
} (constants));
|
|
817
714
|
return constants;
|
|
@@ -823,13 +720,16 @@
|
|
|
823
720
|
if (hasRequiredUtilities$2) return utilities$2;
|
|
824
721
|
hasRequiredUtilities$2 = 1;
|
|
825
722
|
Object.defineProperty(utilities$2, "__esModule", { value: true });
|
|
826
|
-
utilities$2.formatAttributes = formatAttributes;
|
|
827
723
|
utilities$2.hasOpenTag = hasOpenTag;
|
|
828
724
|
utilities$2.escapeSpecialCharacters = escapeSpecialCharacters;
|
|
829
725
|
utilities$2.revertEscapedCharacters = revertEscapedCharacters;
|
|
830
726
|
utilities$2.formatDOM = formatDOM;
|
|
831
|
-
var domhandler_1 =
|
|
727
|
+
var domhandler_1 = require$$3;
|
|
832
728
|
var constants_1 = requireConstants();
|
|
729
|
+
var CARRIAGE_RETURN = '\r';
|
|
730
|
+
var CARRIAGE_RETURN_REGEX = new RegExp(CARRIAGE_RETURN, 'g');
|
|
731
|
+
var CARRIAGE_RETURN_PLACEHOLDER = "__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now().toString(), "__");
|
|
732
|
+
var CARRIAGE_RETURN_PLACEHOLDER_REGEX = new RegExp(CARRIAGE_RETURN_PLACEHOLDER, 'g');
|
|
833
733
|
/**
|
|
834
734
|
* Gets case-sensitive tag name.
|
|
835
735
|
*
|
|
@@ -900,7 +800,7 @@
|
|
|
900
800
|
* @returns - HTML string with escaped special characters.
|
|
901
801
|
*/
|
|
902
802
|
function escapeSpecialCharacters(html) {
|
|
903
|
-
return html.replace(
|
|
803
|
+
return html.replace(CARRIAGE_RETURN_REGEX, CARRIAGE_RETURN_PLACEHOLDER);
|
|
904
804
|
}
|
|
905
805
|
/**
|
|
906
806
|
* Reverts escaped special characters back to actual characters.
|
|
@@ -909,7 +809,7 @@
|
|
|
909
809
|
* @returns - Text with escaped characters reverted.
|
|
910
810
|
*/
|
|
911
811
|
function revertEscapedCharacters(text) {
|
|
912
|
-
return text.replace(
|
|
812
|
+
return text.replace(CARRIAGE_RETURN_PLACEHOLDER_REGEX, CARRIAGE_RETURN);
|
|
913
813
|
}
|
|
914
814
|
/**
|
|
915
815
|
* Transforms DOM nodes to `domhandler` nodes.
|
|
@@ -941,12 +841,14 @@
|
|
|
941
841
|
: node.childNodes, current);
|
|
942
842
|
break;
|
|
943
843
|
}
|
|
844
|
+
/* v8 ignore start */
|
|
944
845
|
case 3:
|
|
945
846
|
current = new domhandler_1.Text(revertEscapedCharacters((_a = node.nodeValue) !== null && _a !== void 0 ? _a : ''));
|
|
946
847
|
break;
|
|
947
848
|
case 8:
|
|
948
849
|
current = new domhandler_1.Comment((_b = node.nodeValue) !== null && _b !== void 0 ? _b : '');
|
|
949
850
|
break;
|
|
851
|
+
/* v8 ignore stop */
|
|
950
852
|
default:
|
|
951
853
|
continue;
|
|
952
854
|
}
|
|
@@ -992,15 +894,13 @@
|
|
|
992
894
|
var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
|
|
993
895
|
// falls back to `parseFromString` if `createHTMLDocument` cannot be used
|
|
994
896
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
995
|
-
/*
|
|
897
|
+
/* v8 ignore start */
|
|
996
898
|
var parseFromDocument = function (html, tagName) {
|
|
997
899
|
throw new Error('This browser does not support `document.implementation.createHTMLDocument`');
|
|
998
900
|
};
|
|
999
901
|
var parseFromString = function (html, tagName) {
|
|
1000
902
|
throw new Error('This browser does not support `DOMParser.prototype.parseFromString`');
|
|
1001
903
|
};
|
|
1002
|
-
/* istanbul ignore stop */
|
|
1003
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
1004
904
|
var DOMParser = typeof window === 'object' && window.DOMParser;
|
|
1005
905
|
/**
|
|
1006
906
|
* DOMParser (performance: slow).
|
|
@@ -1018,11 +918,9 @@
|
|
|
1018
918
|
* @returns - Document.
|
|
1019
919
|
*/
|
|
1020
920
|
parseFromString = function (html, tagName) {
|
|
1021
|
-
/* istanbul ignore start */
|
|
1022
921
|
if (tagName) {
|
|
1023
922
|
html = "<".concat(tagName, ">").concat(html, "</").concat(tagName, ">");
|
|
1024
923
|
}
|
|
1025
|
-
/* istanbul ignore stop */
|
|
1026
924
|
return domParser_1.parseFromString(html, mimeType_1);
|
|
1027
925
|
};
|
|
1028
926
|
parseFromDocument = parseFromString;
|
|
@@ -1043,7 +941,6 @@
|
|
|
1043
941
|
* @returns - Document
|
|
1044
942
|
*/
|
|
1045
943
|
parseFromDocument = function (html, tagName) {
|
|
1046
|
-
/* istanbul ignore start */
|
|
1047
944
|
if (tagName) {
|
|
1048
945
|
var element = htmlDocument_1.documentElement.querySelector(tagName);
|
|
1049
946
|
if (element) {
|
|
@@ -1051,7 +948,6 @@
|
|
|
1051
948
|
}
|
|
1052
949
|
return htmlDocument_1;
|
|
1053
950
|
}
|
|
1054
|
-
/* istanbul ignore stop */
|
|
1055
951
|
htmlDocument_1.documentElement.innerHTML = html;
|
|
1056
952
|
return htmlDocument_1;
|
|
1057
953
|
};
|
|
@@ -1076,9 +972,8 @@
|
|
|
1076
972
|
return template.content.childNodes;
|
|
1077
973
|
};
|
|
1078
974
|
}
|
|
1079
|
-
var createNodeList =
|
|
1080
|
-
|
|
1081
|
-
};
|
|
975
|
+
var createNodeList = function () { return document.createDocumentFragment().childNodes; };
|
|
976
|
+
/* v8 ignore stop */
|
|
1082
977
|
/**
|
|
1083
978
|
* Parses HTML string to DOM nodes.
|
|
1084
979
|
*
|
|
@@ -1098,12 +993,10 @@
|
|
|
1098
993
|
// so make sure to remove them if they don't actually exist
|
|
1099
994
|
if (!(0, utilities_1.hasOpenTag)(html, HEAD)) {
|
|
1100
995
|
var element = doc.querySelector(HEAD);
|
|
1101
|
-
/* istanbul ignore next */
|
|
1102
996
|
(_b = element === null || element === void 0 ? void 0 : element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
|
|
1103
997
|
}
|
|
1104
998
|
if (!(0, utilities_1.hasOpenTag)(html, BODY)) {
|
|
1105
999
|
var element = doc.querySelector(BODY);
|
|
1106
|
-
/* istanbul ignore next */
|
|
1107
1000
|
(_c = element === null || element === void 0 ? void 0 : element.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(element);
|
|
1108
1001
|
}
|
|
1109
1002
|
return doc.querySelectorAll(HTML);
|
|
@@ -1112,23 +1005,23 @@
|
|
|
1112
1005
|
case BODY: {
|
|
1113
1006
|
var elements = parseFromDocument(html).querySelectorAll(firstTagName);
|
|
1114
1007
|
// if there's a sibling element, then return both elements
|
|
1008
|
+
/* v8 ignore next */
|
|
1115
1009
|
if ((0, utilities_1.hasOpenTag)(html, BODY) && (0, utilities_1.hasOpenTag)(html, HEAD)) {
|
|
1116
|
-
/* istanbul ignore next */
|
|
1117
1010
|
return (_e = (_d = elements[0].parentNode) === null || _d === void 0 ? void 0 : _d.childNodes) !== null && _e !== void 0 ? _e : createNodeList();
|
|
1118
1011
|
}
|
|
1119
1012
|
return elements;
|
|
1120
1013
|
}
|
|
1121
1014
|
// low-level tag or text
|
|
1015
|
+
/* v8 ignore start */
|
|
1122
1016
|
default: {
|
|
1123
1017
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1124
1018
|
if (parseFromTemplate) {
|
|
1125
1019
|
return parseFromTemplate(html);
|
|
1126
1020
|
}
|
|
1127
|
-
/* istanbul ignore start */
|
|
1128
1021
|
var element = parseFromDocument(html, BODY).querySelector(BODY);
|
|
1129
1022
|
return (_f = element === null || element === void 0 ? void 0 : element.childNodes) !== null && _f !== void 0 ? _f : createNodeList();
|
|
1130
|
-
/* istanbul ignore stop */
|
|
1131
1023
|
}
|
|
1024
|
+
/* v8 ignore stop */
|
|
1132
1025
|
}
|
|
1133
1026
|
}
|
|
1134
1027
|
|
|
@@ -2631,9 +2524,9 @@
|
|
|
2631
2524
|
exports$1.returnFirstArg = exports$1.canTextBeChildOfNode = exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports$1.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
2632
2525
|
exports$1.isCustomComponent = isCustomComponent;
|
|
2633
2526
|
exports$1.setStyleProp = setStyleProp;
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2527
|
+
const react_1 = require$$0;
|
|
2528
|
+
const style_to_js_1 = __importDefault(requireCjs());
|
|
2529
|
+
const RESERVED_SVG_MATHML_ELEMENTS = new Set([
|
|
2637
2530
|
'annotation-xml',
|
|
2638
2531
|
'color-profile',
|
|
2639
2532
|
'font-face',
|
|
@@ -2665,7 +2558,7 @@
|
|
|
2665
2558
|
}
|
|
2666
2559
|
return true;
|
|
2667
2560
|
}
|
|
2668
|
-
|
|
2561
|
+
const styleOptions = {
|
|
2669
2562
|
reactCompat: true,
|
|
2670
2563
|
};
|
|
2671
2564
|
/**
|
|
@@ -2714,9 +2607,7 @@
|
|
|
2714
2607
|
* @param node - Element node.
|
|
2715
2608
|
* @returns - Whether the node can contain text nodes.
|
|
2716
2609
|
*/
|
|
2717
|
-
|
|
2718
|
-
return !exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2719
|
-
};
|
|
2610
|
+
const canTextBeChildOfNode = (node) => !exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2720
2611
|
exports$1.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2721
2612
|
/**
|
|
2722
2613
|
* Returns the first argument as is.
|
|
@@ -2724,7 +2615,7 @@
|
|
|
2724
2615
|
* @param arg - The argument to be returned.
|
|
2725
2616
|
* @returns - The input argument `arg`.
|
|
2726
2617
|
*/
|
|
2727
|
-
|
|
2618
|
+
const returnFirstArg = (arg) => arg;
|
|
2728
2619
|
exports$1.returnFirstArg = returnFirstArg;
|
|
2729
2620
|
|
|
2730
2621
|
} (utilities$1));
|
|
@@ -2738,13 +2629,13 @@
|
|
|
2738
2629
|
hasRequiredAttributesToProps = 1;
|
|
2739
2630
|
Object.defineProperty(attributesToProps, "__esModule", { value: true });
|
|
2740
2631
|
attributesToProps.default = attributesToProps$1;
|
|
2741
|
-
|
|
2742
|
-
|
|
2632
|
+
const react_property_1 = requireLib$1();
|
|
2633
|
+
const utilities_1 = requireUtilities();
|
|
2743
2634
|
// https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components
|
|
2744
2635
|
// https://developer.mozilla.org/docs/Web/HTML/Attributes
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2636
|
+
const UNCONTROLLED_COMPONENT_ATTRIBUTES = ['checked', 'value'];
|
|
2637
|
+
const UNCONTROLLED_COMPONENT_NAMES = ['input', 'select', 'textarea'];
|
|
2638
|
+
const valueOnlyInputs = {
|
|
2748
2639
|
reset: true,
|
|
2749
2640
|
submit: true,
|
|
2750
2641
|
};
|
|
@@ -2755,22 +2646,21 @@
|
|
|
2755
2646
|
* @param nodeName - DOM node name.
|
|
2756
2647
|
* @returns - React props.
|
|
2757
2648
|
*/
|
|
2758
|
-
function attributesToProps$1(attributes, nodeName) {
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
var attributeValue = attributes[attributeName];
|
|
2649
|
+
function attributesToProps$1(attributes = {}, nodeName) {
|
|
2650
|
+
const props = {};
|
|
2651
|
+
const isInputValueOnly = Boolean(attributes.type && valueOnlyInputs[attributes.type]);
|
|
2652
|
+
for (const attributeName in attributes) {
|
|
2653
|
+
const attributeValue = attributes[attributeName];
|
|
2764
2654
|
// ARIA (aria-*) or custom data (data-*) attribute
|
|
2765
2655
|
if ((0, react_property_1.isCustomAttribute)(attributeName)) {
|
|
2766
2656
|
props[attributeName] = attributeValue;
|
|
2767
2657
|
continue;
|
|
2768
2658
|
}
|
|
2769
2659
|
// convert HTML/SVG attribute to React prop
|
|
2770
|
-
|
|
2771
|
-
|
|
2660
|
+
const attributeNameLowerCased = attributeName.toLowerCase();
|
|
2661
|
+
let propName = getPropName(attributeNameLowerCased);
|
|
2772
2662
|
if (propName) {
|
|
2773
|
-
|
|
2663
|
+
const propertyInfo = (0, react_property_1.getPropertyInfo)(propName);
|
|
2774
2664
|
// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
|
|
2775
2665
|
if (UNCONTROLLED_COMPONENT_ATTRIBUTES.includes(propName) &&
|
|
2776
2666
|
UNCONTROLLED_COMPONENT_NAMES.includes(nodeName) &&
|
|
@@ -2825,10 +2715,10 @@
|
|
|
2825
2715
|
};
|
|
2826
2716
|
Object.defineProperty(domToReact, "__esModule", { value: true });
|
|
2827
2717
|
domToReact.default = domToReact$1;
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2718
|
+
const react_1 = require$$0;
|
|
2719
|
+
const attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
2720
|
+
const utilities_1 = requireUtilities();
|
|
2721
|
+
const React = {
|
|
2832
2722
|
cloneElement: react_1.cloneElement,
|
|
2833
2723
|
createElement: react_1.createElement,
|
|
2834
2724
|
isValidElement: react_1.isValidElement,
|
|
@@ -2840,19 +2730,18 @@
|
|
|
2840
2730
|
* @param options - Options.
|
|
2841
2731
|
* @returns - String or JSX element(s).
|
|
2842
2732
|
*/
|
|
2843
|
-
function domToReact$1(nodes, options) {
|
|
2733
|
+
function domToReact$1(nodes, options = {}) {
|
|
2844
2734
|
var _a, _b, _c, _d, _e;
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
var node = nodes[index];
|
|
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];
|
|
2853
2742
|
// replace with custom React element (if present)
|
|
2854
2743
|
if (hasReplace) {
|
|
2855
|
-
|
|
2744
|
+
let replaceElement = (_c = options.replace) === null || _c === void 0 ? void 0 : _c.call(options, node, index);
|
|
2856
2745
|
if (isValidElement(replaceElement)) {
|
|
2857
2746
|
// set "key" prop for sibling elements
|
|
2858
2747
|
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
@@ -2866,7 +2755,7 @@
|
|
|
2866
2755
|
}
|
|
2867
2756
|
}
|
|
2868
2757
|
if (node.type === 'text') {
|
|
2869
|
-
|
|
2758
|
+
const isWhitespace = !node.data.trim().length;
|
|
2870
2759
|
// We have a whitespace node that can't be nested in its parent
|
|
2871
2760
|
// so skip it
|
|
2872
2761
|
if (isWhitespace &&
|
|
@@ -2884,8 +2773,8 @@
|
|
|
2884
2773
|
reactElements.push(transform(node.data, node, index));
|
|
2885
2774
|
continue;
|
|
2886
2775
|
}
|
|
2887
|
-
|
|
2888
|
-
|
|
2776
|
+
const element = node;
|
|
2777
|
+
let props = {};
|
|
2889
2778
|
if (skipAttributesToProps(element)) {
|
|
2890
2779
|
(0, utilities_1.setStyleProp)(element.attribs.style, element.attribs);
|
|
2891
2780
|
props = element.attribs;
|
|
@@ -2894,7 +2783,7 @@
|
|
|
2894
2783
|
else if (element.attribs) {
|
|
2895
2784
|
props = (0, attributes_to_props_1.default)(element.attribs, element.name);
|
|
2896
2785
|
}
|
|
2897
|
-
|
|
2786
|
+
let children;
|
|
2898
2787
|
switch (node.type) {
|
|
2899
2788
|
case 'script':
|
|
2900
2789
|
case 'style':
|
|
@@ -2950,27 +2839,27 @@
|
|
|
2950
2839
|
var hasRequiredLib;
|
|
2951
2840
|
|
|
2952
2841
|
function requireLib () {
|
|
2953
|
-
if (hasRequiredLib) return lib$
|
|
2842
|
+
if (hasRequiredLib) return lib$1;
|
|
2954
2843
|
hasRequiredLib = 1;
|
|
2955
2844
|
(function (exports$1) {
|
|
2956
|
-
var __importDefault = (lib$
|
|
2845
|
+
var __importDefault = (lib$1 && lib$1.__importDefault) || function (mod) {
|
|
2957
2846
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2958
2847
|
};
|
|
2959
2848
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
2960
2849
|
exports$1.htmlToDOM = exports$1.domToReact = exports$1.attributesToProps = exports$1.Text = exports$1.ProcessingInstruction = exports$1.Element = exports$1.Comment = void 0;
|
|
2961
2850
|
exports$1.default = HTMLReactParser;
|
|
2962
|
-
|
|
2851
|
+
const html_dom_parser_1 = __importDefault(requireHtmlToDom());
|
|
2963
2852
|
exports$1.htmlToDOM = html_dom_parser_1.default;
|
|
2964
|
-
|
|
2853
|
+
const attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
2965
2854
|
exports$1.attributesToProps = attributes_to_props_1.default;
|
|
2966
|
-
|
|
2855
|
+
const dom_to_react_1 = __importDefault(requireDomToReact());
|
|
2967
2856
|
exports$1.domToReact = dom_to_react_1.default;
|
|
2968
|
-
var domhandler_1 =
|
|
2857
|
+
var domhandler_1 = require$$3;
|
|
2969
2858
|
Object.defineProperty(exports$1, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
|
|
2970
2859
|
Object.defineProperty(exports$1, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
|
|
2971
2860
|
Object.defineProperty(exports$1, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
|
|
2972
2861
|
Object.defineProperty(exports$1, "Text", { enumerable: true, get: function () { return domhandler_1.Text; } });
|
|
2973
|
-
|
|
2862
|
+
const domParserOptions = { lowerCaseAttributeNames: false };
|
|
2974
2863
|
/**
|
|
2975
2864
|
* Converts HTML string to React elements.
|
|
2976
2865
|
*
|
|
@@ -2989,8 +2878,8 @@
|
|
|
2989
2878
|
return (0, dom_to_react_1.default)((0, html_dom_parser_1.default)(html, (_a = options === null || options === void 0 ? void 0 : options.htmlparser2) !== null && _a !== void 0 ? _a : domParserOptions), options);
|
|
2990
2879
|
}
|
|
2991
2880
|
|
|
2992
|
-
} (lib$
|
|
2993
|
-
return lib$
|
|
2881
|
+
} (lib$1));
|
|
2882
|
+
return lib$1;
|
|
2994
2883
|
}
|
|
2995
2884
|
|
|
2996
2885
|
var libExports = requireLib();
|