parse5 7.1.1 → 7.2.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/cjs/common/doctype.d.ts +0 -1
- package/dist/cjs/common/doctype.js +2 -4
- package/dist/cjs/common/error-codes.d.ts +1 -2
- package/dist/cjs/common/error-codes.js +1 -2
- package/dist/cjs/common/foreign-content.d.ts +0 -1
- package/dist/cjs/common/foreign-content.js +7 -9
- package/dist/cjs/common/html.d.ts +32 -31
- package/dist/cjs/common/html.js +41 -42
- package/dist/cjs/common/token.d.ts +1 -2
- package/dist/cjs/common/token.js +3 -4
- package/dist/cjs/common/unicode.d.ts +1 -8
- package/dist/cjs/common/unicode.js +7 -14
- package/dist/cjs/index.d.ts +2 -4
- package/dist/cjs/index.js +5 -6
- package/dist/cjs/parser/formatting-element-list.d.ts +1 -2
- package/dist/cjs/parser/formatting-element-list.js +1 -2
- package/dist/cjs/parser/index.d.ts +72 -8
- package/dist/cjs/parser/index.js +301 -119
- package/dist/cjs/parser/open-element-stack.d.ts +2 -2
- package/dist/cjs/parser/open-element-stack.js +98 -90
- package/dist/cjs/serializer/index.d.ts +1 -2
- package/dist/cjs/serializer/index.js +8 -9
- package/dist/cjs/tokenizer/index.d.ts +130 -131
- package/dist/cjs/tokenizer/index.js +89 -282
- package/dist/cjs/tokenizer/preprocessor.d.ts +3 -4
- package/dist/cjs/tokenizer/preprocessor.js +10 -8
- package/dist/cjs/tree-adapters/default.d.ts +4 -5
- package/dist/cjs/tree-adapters/default.js +9 -10
- package/dist/cjs/tree-adapters/interface.d.ts +7 -2
- package/dist/cjs/tree-adapters/interface.js +0 -1
- package/dist/common/doctype.d.ts +0 -1
- package/dist/common/doctype.js +0 -1
- package/dist/common/error-codes.d.ts +1 -2
- package/dist/common/error-codes.js +1 -2
- package/dist/common/foreign-content.d.ts +0 -1
- package/dist/common/foreign-content.js +0 -2
- package/dist/common/html.d.ts +32 -31
- package/dist/common/html.js +38 -38
- package/dist/common/token.d.ts +1 -2
- package/dist/common/token.js +1 -2
- package/dist/common/unicode.d.ts +1 -8
- package/dist/common/unicode.js +1 -8
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -3
- package/dist/parser/formatting-element-list.d.ts +1 -2
- package/dist/parser/formatting-element-list.js +1 -2
- package/dist/parser/index.d.ts +72 -8
- package/dist/parser/index.js +302 -120
- package/dist/parser/open-element-stack.d.ts +2 -2
- package/dist/parser/open-element-stack.js +99 -91
- package/dist/serializer/index.d.ts +1 -2
- package/dist/serializer/index.js +6 -6
- package/dist/tokenizer/index.d.ts +130 -131
- package/dist/tokenizer/index.js +90 -283
- package/dist/tokenizer/preprocessor.d.ts +3 -4
- package/dist/tokenizer/preprocessor.js +10 -8
- package/dist/tree-adapters/default.d.ts +4 -5
- package/dist/tree-adapters/default.js +9 -10
- package/dist/tree-adapters/interface.d.ts +7 -2
- package/dist/tree-adapters/interface.js +0 -1
- package/package.json +4 -4
package/dist/parser/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as doctype from '../common/doctype.js';
|
|
|
6
6
|
import * as foreignContent from '../common/foreign-content.js';
|
|
7
7
|
import { ERR } from '../common/error-codes.js';
|
|
8
8
|
import * as unicode from '../common/unicode.js';
|
|
9
|
-
import { TAG_ID as $, TAG_NAMES as TN, NS, ATTRS, SPECIAL_ELEMENTS, DOCUMENT_MODE,
|
|
9
|
+
import { TAG_ID as $, TAG_NAMES as TN, NS, ATTRS, SPECIAL_ELEMENTS, DOCUMENT_MODE, NUMBERED_HEADERS, getTagID, } from '../common/html.js';
|
|
10
10
|
import { TokenType, getTokenAttr, } from '../common/token.js';
|
|
11
11
|
//Misc constants
|
|
12
12
|
const HIDDEN_INPUT_TYPE = 'hidden';
|
|
@@ -57,26 +57,41 @@ const defaultParserOptions = {
|
|
|
57
57
|
};
|
|
58
58
|
//Parser
|
|
59
59
|
export class Parser {
|
|
60
|
-
constructor(options, document,
|
|
60
|
+
constructor(options, document,
|
|
61
|
+
/** @internal */
|
|
62
|
+
fragmentContext = null,
|
|
63
|
+
/** @internal */
|
|
64
|
+
scriptHandler = null) {
|
|
61
65
|
this.fragmentContext = fragmentContext;
|
|
62
66
|
this.scriptHandler = scriptHandler;
|
|
63
67
|
this.currentToken = null;
|
|
64
68
|
this.stopped = false;
|
|
69
|
+
/** @internal */
|
|
65
70
|
this.insertionMode = InsertionMode.INITIAL;
|
|
71
|
+
/** @internal */
|
|
66
72
|
this.originalInsertionMode = InsertionMode.INITIAL;
|
|
73
|
+
/** @internal */
|
|
67
74
|
this.headElement = null;
|
|
75
|
+
/** @internal */
|
|
68
76
|
this.formElement = null;
|
|
69
77
|
/** Indicates that the current node is not an element in the HTML namespace */
|
|
70
78
|
this.currentNotInHTML = false;
|
|
71
79
|
/**
|
|
72
80
|
* The template insertion mode stack is maintained from the left.
|
|
73
81
|
* Ie. the topmost element will always have index 0.
|
|
82
|
+
*
|
|
83
|
+
* @internal
|
|
74
84
|
*/
|
|
75
85
|
this.tmplInsertionModeStack = [];
|
|
86
|
+
/** @internal */
|
|
76
87
|
this.pendingCharacterTokens = [];
|
|
88
|
+
/** @internal */
|
|
77
89
|
this.hasNonWhitespacePendingCharacterToken = false;
|
|
90
|
+
/** @internal */
|
|
78
91
|
this.framesetOk = true;
|
|
92
|
+
/** @internal */
|
|
79
93
|
this.skipNextNewLine = false;
|
|
94
|
+
/** @internal */
|
|
80
95
|
this.fosterParentingEnabled = false;
|
|
81
96
|
this.options = {
|
|
82
97
|
...defaultParserOptions,
|
|
@@ -130,6 +145,7 @@ export class Parser {
|
|
|
130
145
|
return fragment;
|
|
131
146
|
}
|
|
132
147
|
//Errors
|
|
148
|
+
/** @internal */
|
|
133
149
|
_err(token, code, beforeToken) {
|
|
134
150
|
var _a;
|
|
135
151
|
if (!this.onParseError)
|
|
@@ -147,12 +163,14 @@ export class Parser {
|
|
|
147
163
|
this.onParseError(err);
|
|
148
164
|
}
|
|
149
165
|
//Stack events
|
|
166
|
+
/** @internal */
|
|
150
167
|
onItemPush(node, tid, isTop) {
|
|
151
168
|
var _a, _b;
|
|
152
169
|
(_b = (_a = this.treeAdapter).onItemPush) === null || _b === void 0 ? void 0 : _b.call(_a, node);
|
|
153
170
|
if (isTop && this.openElements.stackTop > 0)
|
|
154
171
|
this._setContextModes(node, tid);
|
|
155
172
|
}
|
|
173
|
+
/** @internal */
|
|
156
174
|
onItemPop(node, isTop) {
|
|
157
175
|
var _a, _b;
|
|
158
176
|
if (this.options.sourceCodeLocationInfo) {
|
|
@@ -177,6 +195,7 @@ export class Parser {
|
|
|
177
195
|
this.currentNotInHTML = !isHTML;
|
|
178
196
|
this.tokenizer.inForeignNode = !isHTML && !this._isIntegrationPoint(tid, current);
|
|
179
197
|
}
|
|
198
|
+
/** @protected */
|
|
180
199
|
_switchToTextParsing(currentToken, nextTokenizerState) {
|
|
181
200
|
this._insertElement(currentToken, NS.HTML);
|
|
182
201
|
this.tokenizer.state = nextTokenizerState;
|
|
@@ -189,11 +208,13 @@ export class Parser {
|
|
|
189
208
|
this.tokenizer.state = TokenizerMode.PLAINTEXT;
|
|
190
209
|
}
|
|
191
210
|
//Fragment parsing
|
|
211
|
+
/** @protected */
|
|
192
212
|
_getAdjustedCurrentElement() {
|
|
193
213
|
return this.openElements.stackTop === 0 && this.fragmentContext
|
|
194
214
|
? this.fragmentContext
|
|
195
215
|
: this.openElements.current;
|
|
196
216
|
}
|
|
217
|
+
/** @protected */
|
|
197
218
|
_findFormInFragmentContext() {
|
|
198
219
|
let node = this.fragmentContext;
|
|
199
220
|
while (node) {
|
|
@@ -236,6 +257,7 @@ export class Parser {
|
|
|
236
257
|
}
|
|
237
258
|
}
|
|
238
259
|
//Tree mutation
|
|
260
|
+
/** @protected */
|
|
239
261
|
_setDocumentType(token) {
|
|
240
262
|
const name = token.name || '';
|
|
241
263
|
const publicId = token.publicId || '';
|
|
@@ -249,6 +271,7 @@ export class Parser {
|
|
|
249
271
|
}
|
|
250
272
|
}
|
|
251
273
|
}
|
|
274
|
+
/** @protected */
|
|
252
275
|
_attachElementToTree(element, location) {
|
|
253
276
|
if (this.options.sourceCodeLocationInfo) {
|
|
254
277
|
const loc = location && {
|
|
@@ -265,20 +288,28 @@ export class Parser {
|
|
|
265
288
|
this.treeAdapter.appendChild(parent, element);
|
|
266
289
|
}
|
|
267
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* For self-closing tags. Add an element to the tree, but skip adding it
|
|
293
|
+
* to the stack.
|
|
294
|
+
*/
|
|
295
|
+
/** @protected */
|
|
268
296
|
_appendElement(token, namespaceURI) {
|
|
269
297
|
const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
|
|
270
298
|
this._attachElementToTree(element, token.location);
|
|
271
299
|
}
|
|
300
|
+
/** @protected */
|
|
272
301
|
_insertElement(token, namespaceURI) {
|
|
273
302
|
const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
|
|
274
303
|
this._attachElementToTree(element, token.location);
|
|
275
304
|
this.openElements.push(element, token.tagID);
|
|
276
305
|
}
|
|
306
|
+
/** @protected */
|
|
277
307
|
_insertFakeElement(tagName, tagID) {
|
|
278
308
|
const element = this.treeAdapter.createElement(tagName, NS.HTML, []);
|
|
279
309
|
this._attachElementToTree(element, null);
|
|
280
310
|
this.openElements.push(element, tagID);
|
|
281
311
|
}
|
|
312
|
+
/** @protected */
|
|
282
313
|
_insertTemplate(token) {
|
|
283
314
|
const tmpl = this.treeAdapter.createElement(token.tagName, NS.HTML, token.attrs);
|
|
284
315
|
const content = this.treeAdapter.createDocumentFragment();
|
|
@@ -288,6 +319,7 @@ export class Parser {
|
|
|
288
319
|
if (this.options.sourceCodeLocationInfo)
|
|
289
320
|
this.treeAdapter.setNodeSourceCodeLocation(content, null);
|
|
290
321
|
}
|
|
322
|
+
/** @protected */
|
|
291
323
|
_insertFakeRootElement() {
|
|
292
324
|
const element = this.treeAdapter.createElement(TN.HTML, NS.HTML, []);
|
|
293
325
|
if (this.options.sourceCodeLocationInfo)
|
|
@@ -295,6 +327,7 @@ export class Parser {
|
|
|
295
327
|
this.treeAdapter.appendChild(this.openElements.current, element);
|
|
296
328
|
this.openElements.push(element, $.HTML);
|
|
297
329
|
}
|
|
330
|
+
/** @protected */
|
|
298
331
|
_appendCommentNode(token, parent) {
|
|
299
332
|
const commentNode = this.treeAdapter.createCommentNode(token.data);
|
|
300
333
|
this.treeAdapter.appendChild(parent, commentNode);
|
|
@@ -302,6 +335,7 @@ export class Parser {
|
|
|
302
335
|
this.treeAdapter.setNodeSourceCodeLocation(commentNode, token.location);
|
|
303
336
|
}
|
|
304
337
|
}
|
|
338
|
+
/** @protected */
|
|
305
339
|
_insertCharacters(token) {
|
|
306
340
|
let parent;
|
|
307
341
|
let beforeElement;
|
|
@@ -333,12 +367,14 @@ export class Parser {
|
|
|
333
367
|
this.treeAdapter.setNodeSourceCodeLocation(textNode, token.location);
|
|
334
368
|
}
|
|
335
369
|
}
|
|
370
|
+
/** @protected */
|
|
336
371
|
_adoptNodes(donor, recipient) {
|
|
337
372
|
for (let child = this.treeAdapter.getFirstChild(donor); child; child = this.treeAdapter.getFirstChild(donor)) {
|
|
338
373
|
this.treeAdapter.detachNode(child);
|
|
339
374
|
this.treeAdapter.appendChild(recipient, child);
|
|
340
375
|
}
|
|
341
376
|
}
|
|
377
|
+
/** @protected */
|
|
342
378
|
_setEndLocation(element, closingToken) {
|
|
343
379
|
if (this.treeAdapter.getNodeSourceCodeLocation(element) && closingToken.location) {
|
|
344
380
|
const ctLoc = closingToken.location;
|
|
@@ -388,6 +424,7 @@ export class Parser {
|
|
|
388
424
|
((token.tagID === $.MGLYPH || token.tagID === $.MALIGNMARK) &&
|
|
389
425
|
!this._isIntegrationPoint(currentTagId, current, NS.HTML)));
|
|
390
426
|
}
|
|
427
|
+
/** @protected */
|
|
391
428
|
_processToken(token) {
|
|
392
429
|
switch (token.type) {
|
|
393
430
|
case TokenType.CHARACTER: {
|
|
@@ -425,12 +462,14 @@ export class Parser {
|
|
|
425
462
|
}
|
|
426
463
|
}
|
|
427
464
|
//Integration points
|
|
465
|
+
/** @protected */
|
|
428
466
|
_isIntegrationPoint(tid, element, foreignNS) {
|
|
429
467
|
const ns = this.treeAdapter.getNamespaceURI(element);
|
|
430
468
|
const attrs = this.treeAdapter.getAttrList(element);
|
|
431
469
|
return foreignContent.isIntegrationPoint(tid, ns, attrs, foreignNS);
|
|
432
470
|
}
|
|
433
471
|
//Active formatting elements reconstruction
|
|
472
|
+
/** @protected */
|
|
434
473
|
_reconstructActiveFormattingElements() {
|
|
435
474
|
const listLength = this.activeFormattingElements.entries.length;
|
|
436
475
|
if (listLength) {
|
|
@@ -444,70 +483,86 @@ export class Parser {
|
|
|
444
483
|
}
|
|
445
484
|
}
|
|
446
485
|
//Close elements
|
|
486
|
+
/** @protected */
|
|
447
487
|
_closeTableCell() {
|
|
448
488
|
this.openElements.generateImpliedEndTags();
|
|
449
489
|
this.openElements.popUntilTableCellPopped();
|
|
450
490
|
this.activeFormattingElements.clearToLastMarker();
|
|
451
491
|
this.insertionMode = InsertionMode.IN_ROW;
|
|
452
492
|
}
|
|
493
|
+
/** @protected */
|
|
453
494
|
_closePElement() {
|
|
454
495
|
this.openElements.generateImpliedEndTagsWithExclusion($.P);
|
|
455
496
|
this.openElements.popUntilTagNamePopped($.P);
|
|
456
497
|
}
|
|
457
498
|
//Insertion modes
|
|
499
|
+
/** @protected */
|
|
458
500
|
_resetInsertionMode() {
|
|
459
501
|
for (let i = this.openElements.stackTop; i >= 0; i--) {
|
|
460
502
|
//Insertion mode reset map
|
|
461
503
|
switch (i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i]) {
|
|
462
|
-
case $.TR:
|
|
504
|
+
case $.TR: {
|
|
463
505
|
this.insertionMode = InsertionMode.IN_ROW;
|
|
464
506
|
return;
|
|
507
|
+
}
|
|
465
508
|
case $.TBODY:
|
|
466
509
|
case $.THEAD:
|
|
467
|
-
case $.TFOOT:
|
|
510
|
+
case $.TFOOT: {
|
|
468
511
|
this.insertionMode = InsertionMode.IN_TABLE_BODY;
|
|
469
512
|
return;
|
|
470
|
-
|
|
513
|
+
}
|
|
514
|
+
case $.CAPTION: {
|
|
471
515
|
this.insertionMode = InsertionMode.IN_CAPTION;
|
|
472
516
|
return;
|
|
473
|
-
|
|
517
|
+
}
|
|
518
|
+
case $.COLGROUP: {
|
|
474
519
|
this.insertionMode = InsertionMode.IN_COLUMN_GROUP;
|
|
475
520
|
return;
|
|
476
|
-
|
|
521
|
+
}
|
|
522
|
+
case $.TABLE: {
|
|
477
523
|
this.insertionMode = InsertionMode.IN_TABLE;
|
|
478
524
|
return;
|
|
479
|
-
|
|
525
|
+
}
|
|
526
|
+
case $.BODY: {
|
|
480
527
|
this.insertionMode = InsertionMode.IN_BODY;
|
|
481
528
|
return;
|
|
482
|
-
|
|
529
|
+
}
|
|
530
|
+
case $.FRAMESET: {
|
|
483
531
|
this.insertionMode = InsertionMode.IN_FRAMESET;
|
|
484
532
|
return;
|
|
485
|
-
|
|
533
|
+
}
|
|
534
|
+
case $.SELECT: {
|
|
486
535
|
this._resetInsertionModeForSelect(i);
|
|
487
536
|
return;
|
|
488
|
-
|
|
537
|
+
}
|
|
538
|
+
case $.TEMPLATE: {
|
|
489
539
|
this.insertionMode = this.tmplInsertionModeStack[0];
|
|
490
540
|
return;
|
|
491
|
-
|
|
541
|
+
}
|
|
542
|
+
case $.HTML: {
|
|
492
543
|
this.insertionMode = this.headElement ? InsertionMode.AFTER_HEAD : InsertionMode.BEFORE_HEAD;
|
|
493
544
|
return;
|
|
545
|
+
}
|
|
494
546
|
case $.TD:
|
|
495
|
-
case $.TH:
|
|
547
|
+
case $.TH: {
|
|
496
548
|
if (i > 0) {
|
|
497
549
|
this.insertionMode = InsertionMode.IN_CELL;
|
|
498
550
|
return;
|
|
499
551
|
}
|
|
500
552
|
break;
|
|
501
|
-
|
|
553
|
+
}
|
|
554
|
+
case $.HEAD: {
|
|
502
555
|
if (i > 0) {
|
|
503
556
|
this.insertionMode = InsertionMode.IN_HEAD;
|
|
504
557
|
return;
|
|
505
558
|
}
|
|
506
559
|
break;
|
|
560
|
+
}
|
|
507
561
|
}
|
|
508
562
|
}
|
|
509
563
|
this.insertionMode = InsertionMode.IN_BODY;
|
|
510
564
|
}
|
|
565
|
+
/** @protected */
|
|
511
566
|
_resetInsertionModeForSelect(selectIdx) {
|
|
512
567
|
if (selectIdx > 0) {
|
|
513
568
|
for (let i = selectIdx - 1; i > 0; i--) {
|
|
@@ -524,21 +579,25 @@ export class Parser {
|
|
|
524
579
|
this.insertionMode = InsertionMode.IN_SELECT;
|
|
525
580
|
}
|
|
526
581
|
//Foster parenting
|
|
582
|
+
/** @protected */
|
|
527
583
|
_isElementCausesFosterParenting(tn) {
|
|
528
584
|
return TABLE_STRUCTURE_TAGS.has(tn);
|
|
529
585
|
}
|
|
586
|
+
/** @protected */
|
|
530
587
|
_shouldFosterParentOnInsertion() {
|
|
531
588
|
return this.fosterParentingEnabled && this._isElementCausesFosterParenting(this.openElements.currentTagId);
|
|
532
589
|
}
|
|
590
|
+
/** @protected */
|
|
533
591
|
_findFosterParentingLocation() {
|
|
534
592
|
for (let i = this.openElements.stackTop; i >= 0; i--) {
|
|
535
593
|
const openElement = this.openElements.items[i];
|
|
536
594
|
switch (this.openElements.tagIDs[i]) {
|
|
537
|
-
case $.TEMPLATE:
|
|
595
|
+
case $.TEMPLATE: {
|
|
538
596
|
if (this.treeAdapter.getNamespaceURI(openElement) === NS.HTML) {
|
|
539
597
|
return { parent: this.treeAdapter.getTemplateContent(openElement), beforeElement: null };
|
|
540
598
|
}
|
|
541
599
|
break;
|
|
600
|
+
}
|
|
542
601
|
case $.TABLE: {
|
|
543
602
|
const parent = this.treeAdapter.getParentNode(openElement);
|
|
544
603
|
if (parent) {
|
|
@@ -552,6 +611,7 @@ export class Parser {
|
|
|
552
611
|
}
|
|
553
612
|
return { parent: this.openElements.items[0], beforeElement: null };
|
|
554
613
|
}
|
|
614
|
+
/** @protected */
|
|
555
615
|
_fosterParentElement(element) {
|
|
556
616
|
const location = this._findFosterParentingLocation();
|
|
557
617
|
if (location.beforeElement) {
|
|
@@ -562,10 +622,12 @@ export class Parser {
|
|
|
562
622
|
}
|
|
563
623
|
}
|
|
564
624
|
//Special elements
|
|
625
|
+
/** @protected */
|
|
565
626
|
_isSpecialElement(element, id) {
|
|
566
627
|
const ns = this.treeAdapter.getNamespaceURI(element);
|
|
567
628
|
return SPECIAL_ELEMENTS[ns].has(id);
|
|
568
629
|
}
|
|
630
|
+
/** @internal */
|
|
569
631
|
onCharacter(token) {
|
|
570
632
|
this.skipNextNewLine = false;
|
|
571
633
|
if (this.tokenizer.inForeignNode) {
|
|
@@ -573,56 +635,70 @@ export class Parser {
|
|
|
573
635
|
return;
|
|
574
636
|
}
|
|
575
637
|
switch (this.insertionMode) {
|
|
576
|
-
case InsertionMode.INITIAL:
|
|
638
|
+
case InsertionMode.INITIAL: {
|
|
577
639
|
tokenInInitialMode(this, token);
|
|
578
640
|
break;
|
|
579
|
-
|
|
641
|
+
}
|
|
642
|
+
case InsertionMode.BEFORE_HTML: {
|
|
580
643
|
tokenBeforeHtml(this, token);
|
|
581
644
|
break;
|
|
582
|
-
|
|
645
|
+
}
|
|
646
|
+
case InsertionMode.BEFORE_HEAD: {
|
|
583
647
|
tokenBeforeHead(this, token);
|
|
584
648
|
break;
|
|
585
|
-
|
|
649
|
+
}
|
|
650
|
+
case InsertionMode.IN_HEAD: {
|
|
586
651
|
tokenInHead(this, token);
|
|
587
652
|
break;
|
|
588
|
-
|
|
653
|
+
}
|
|
654
|
+
case InsertionMode.IN_HEAD_NO_SCRIPT: {
|
|
589
655
|
tokenInHeadNoScript(this, token);
|
|
590
656
|
break;
|
|
591
|
-
|
|
657
|
+
}
|
|
658
|
+
case InsertionMode.AFTER_HEAD: {
|
|
592
659
|
tokenAfterHead(this, token);
|
|
593
660
|
break;
|
|
661
|
+
}
|
|
594
662
|
case InsertionMode.IN_BODY:
|
|
595
663
|
case InsertionMode.IN_CAPTION:
|
|
596
664
|
case InsertionMode.IN_CELL:
|
|
597
|
-
case InsertionMode.IN_TEMPLATE:
|
|
665
|
+
case InsertionMode.IN_TEMPLATE: {
|
|
598
666
|
characterInBody(this, token);
|
|
599
667
|
break;
|
|
668
|
+
}
|
|
600
669
|
case InsertionMode.TEXT:
|
|
601
670
|
case InsertionMode.IN_SELECT:
|
|
602
|
-
case InsertionMode.IN_SELECT_IN_TABLE:
|
|
671
|
+
case InsertionMode.IN_SELECT_IN_TABLE: {
|
|
603
672
|
this._insertCharacters(token);
|
|
604
673
|
break;
|
|
674
|
+
}
|
|
605
675
|
case InsertionMode.IN_TABLE:
|
|
606
676
|
case InsertionMode.IN_TABLE_BODY:
|
|
607
|
-
case InsertionMode.IN_ROW:
|
|
677
|
+
case InsertionMode.IN_ROW: {
|
|
608
678
|
characterInTable(this, token);
|
|
609
679
|
break;
|
|
610
|
-
|
|
680
|
+
}
|
|
681
|
+
case InsertionMode.IN_TABLE_TEXT: {
|
|
611
682
|
characterInTableText(this, token);
|
|
612
683
|
break;
|
|
613
|
-
|
|
684
|
+
}
|
|
685
|
+
case InsertionMode.IN_COLUMN_GROUP: {
|
|
614
686
|
tokenInColumnGroup(this, token);
|
|
615
687
|
break;
|
|
616
|
-
|
|
688
|
+
}
|
|
689
|
+
case InsertionMode.AFTER_BODY: {
|
|
617
690
|
tokenAfterBody(this, token);
|
|
618
691
|
break;
|
|
619
|
-
|
|
692
|
+
}
|
|
693
|
+
case InsertionMode.AFTER_AFTER_BODY: {
|
|
620
694
|
tokenAfterAfterBody(this, token);
|
|
621
695
|
break;
|
|
696
|
+
}
|
|
622
697
|
default:
|
|
623
698
|
// Do nothing
|
|
624
699
|
}
|
|
625
700
|
}
|
|
701
|
+
/** @internal */
|
|
626
702
|
onNullCharacter(token) {
|
|
627
703
|
this.skipNextNewLine = false;
|
|
628
704
|
if (this.tokenizer.inForeignNode) {
|
|
@@ -630,45 +706,57 @@ export class Parser {
|
|
|
630
706
|
return;
|
|
631
707
|
}
|
|
632
708
|
switch (this.insertionMode) {
|
|
633
|
-
case InsertionMode.INITIAL:
|
|
709
|
+
case InsertionMode.INITIAL: {
|
|
634
710
|
tokenInInitialMode(this, token);
|
|
635
711
|
break;
|
|
636
|
-
|
|
712
|
+
}
|
|
713
|
+
case InsertionMode.BEFORE_HTML: {
|
|
637
714
|
tokenBeforeHtml(this, token);
|
|
638
715
|
break;
|
|
639
|
-
|
|
716
|
+
}
|
|
717
|
+
case InsertionMode.BEFORE_HEAD: {
|
|
640
718
|
tokenBeforeHead(this, token);
|
|
641
719
|
break;
|
|
642
|
-
|
|
720
|
+
}
|
|
721
|
+
case InsertionMode.IN_HEAD: {
|
|
643
722
|
tokenInHead(this, token);
|
|
644
723
|
break;
|
|
645
|
-
|
|
724
|
+
}
|
|
725
|
+
case InsertionMode.IN_HEAD_NO_SCRIPT: {
|
|
646
726
|
tokenInHeadNoScript(this, token);
|
|
647
727
|
break;
|
|
648
|
-
|
|
728
|
+
}
|
|
729
|
+
case InsertionMode.AFTER_HEAD: {
|
|
649
730
|
tokenAfterHead(this, token);
|
|
650
731
|
break;
|
|
651
|
-
|
|
732
|
+
}
|
|
733
|
+
case InsertionMode.TEXT: {
|
|
652
734
|
this._insertCharacters(token);
|
|
653
735
|
break;
|
|
736
|
+
}
|
|
654
737
|
case InsertionMode.IN_TABLE:
|
|
655
738
|
case InsertionMode.IN_TABLE_BODY:
|
|
656
|
-
case InsertionMode.IN_ROW:
|
|
739
|
+
case InsertionMode.IN_ROW: {
|
|
657
740
|
characterInTable(this, token);
|
|
658
741
|
break;
|
|
659
|
-
|
|
742
|
+
}
|
|
743
|
+
case InsertionMode.IN_COLUMN_GROUP: {
|
|
660
744
|
tokenInColumnGroup(this, token);
|
|
661
745
|
break;
|
|
662
|
-
|
|
746
|
+
}
|
|
747
|
+
case InsertionMode.AFTER_BODY: {
|
|
663
748
|
tokenAfterBody(this, token);
|
|
664
749
|
break;
|
|
665
|
-
|
|
750
|
+
}
|
|
751
|
+
case InsertionMode.AFTER_AFTER_BODY: {
|
|
666
752
|
tokenAfterAfterBody(this, token);
|
|
667
753
|
break;
|
|
754
|
+
}
|
|
668
755
|
default:
|
|
669
756
|
// Do nothing
|
|
670
757
|
}
|
|
671
758
|
}
|
|
759
|
+
/** @internal */
|
|
672
760
|
onComment(token) {
|
|
673
761
|
this.skipNextNewLine = false;
|
|
674
762
|
if (this.currentNotInHTML) {
|
|
@@ -693,42 +781,51 @@ export class Parser {
|
|
|
693
781
|
case InsertionMode.IN_SELECT_IN_TABLE:
|
|
694
782
|
case InsertionMode.IN_TEMPLATE:
|
|
695
783
|
case InsertionMode.IN_FRAMESET:
|
|
696
|
-
case InsertionMode.AFTER_FRAMESET:
|
|
784
|
+
case InsertionMode.AFTER_FRAMESET: {
|
|
697
785
|
appendComment(this, token);
|
|
698
786
|
break;
|
|
699
|
-
|
|
787
|
+
}
|
|
788
|
+
case InsertionMode.IN_TABLE_TEXT: {
|
|
700
789
|
tokenInTableText(this, token);
|
|
701
790
|
break;
|
|
702
|
-
|
|
791
|
+
}
|
|
792
|
+
case InsertionMode.AFTER_BODY: {
|
|
703
793
|
appendCommentToRootHtmlElement(this, token);
|
|
704
794
|
break;
|
|
795
|
+
}
|
|
705
796
|
case InsertionMode.AFTER_AFTER_BODY:
|
|
706
|
-
case InsertionMode.AFTER_AFTER_FRAMESET:
|
|
797
|
+
case InsertionMode.AFTER_AFTER_FRAMESET: {
|
|
707
798
|
appendCommentToDocument(this, token);
|
|
708
799
|
break;
|
|
800
|
+
}
|
|
709
801
|
default:
|
|
710
802
|
// Do nothing
|
|
711
803
|
}
|
|
712
804
|
}
|
|
805
|
+
/** @internal */
|
|
713
806
|
onDoctype(token) {
|
|
714
807
|
this.skipNextNewLine = false;
|
|
715
808
|
switch (this.insertionMode) {
|
|
716
|
-
case InsertionMode.INITIAL:
|
|
809
|
+
case InsertionMode.INITIAL: {
|
|
717
810
|
doctypeInInitialMode(this, token);
|
|
718
811
|
break;
|
|
812
|
+
}
|
|
719
813
|
case InsertionMode.BEFORE_HEAD:
|
|
720
814
|
case InsertionMode.IN_HEAD:
|
|
721
815
|
case InsertionMode.IN_HEAD_NO_SCRIPT:
|
|
722
|
-
case InsertionMode.AFTER_HEAD:
|
|
816
|
+
case InsertionMode.AFTER_HEAD: {
|
|
723
817
|
this._err(token, ERR.misplacedDoctype);
|
|
724
818
|
break;
|
|
725
|
-
|
|
819
|
+
}
|
|
820
|
+
case InsertionMode.IN_TABLE_TEXT: {
|
|
726
821
|
tokenInTableText(this, token);
|
|
727
822
|
break;
|
|
823
|
+
}
|
|
728
824
|
default:
|
|
729
825
|
// Do nothing
|
|
730
826
|
}
|
|
731
827
|
}
|
|
828
|
+
/** @internal */
|
|
732
829
|
onStartTag(token) {
|
|
733
830
|
this.skipNextNewLine = false;
|
|
734
831
|
this.currentToken = token;
|
|
@@ -746,6 +843,7 @@ export class Parser {
|
|
|
746
843
|
* for nested calls.
|
|
747
844
|
*
|
|
748
845
|
* @param token The token to process.
|
|
846
|
+
* @protected
|
|
749
847
|
*/
|
|
750
848
|
_processStartTag(token) {
|
|
751
849
|
if (this.shouldProcessStartTagTokenInForeignContent(token)) {
|
|
@@ -755,78 +853,102 @@ export class Parser {
|
|
|
755
853
|
this._startTagOutsideForeignContent(token);
|
|
756
854
|
}
|
|
757
855
|
}
|
|
856
|
+
/** @protected */
|
|
758
857
|
_startTagOutsideForeignContent(token) {
|
|
759
858
|
switch (this.insertionMode) {
|
|
760
|
-
case InsertionMode.INITIAL:
|
|
859
|
+
case InsertionMode.INITIAL: {
|
|
761
860
|
tokenInInitialMode(this, token);
|
|
762
861
|
break;
|
|
763
|
-
|
|
862
|
+
}
|
|
863
|
+
case InsertionMode.BEFORE_HTML: {
|
|
764
864
|
startTagBeforeHtml(this, token);
|
|
765
865
|
break;
|
|
766
|
-
|
|
866
|
+
}
|
|
867
|
+
case InsertionMode.BEFORE_HEAD: {
|
|
767
868
|
startTagBeforeHead(this, token);
|
|
768
869
|
break;
|
|
769
|
-
|
|
870
|
+
}
|
|
871
|
+
case InsertionMode.IN_HEAD: {
|
|
770
872
|
startTagInHead(this, token);
|
|
771
873
|
break;
|
|
772
|
-
|
|
874
|
+
}
|
|
875
|
+
case InsertionMode.IN_HEAD_NO_SCRIPT: {
|
|
773
876
|
startTagInHeadNoScript(this, token);
|
|
774
877
|
break;
|
|
775
|
-
|
|
878
|
+
}
|
|
879
|
+
case InsertionMode.AFTER_HEAD: {
|
|
776
880
|
startTagAfterHead(this, token);
|
|
777
881
|
break;
|
|
778
|
-
|
|
882
|
+
}
|
|
883
|
+
case InsertionMode.IN_BODY: {
|
|
779
884
|
startTagInBody(this, token);
|
|
780
885
|
break;
|
|
781
|
-
|
|
886
|
+
}
|
|
887
|
+
case InsertionMode.IN_TABLE: {
|
|
782
888
|
startTagInTable(this, token);
|
|
783
889
|
break;
|
|
784
|
-
|
|
890
|
+
}
|
|
891
|
+
case InsertionMode.IN_TABLE_TEXT: {
|
|
785
892
|
tokenInTableText(this, token);
|
|
786
893
|
break;
|
|
787
|
-
|
|
894
|
+
}
|
|
895
|
+
case InsertionMode.IN_CAPTION: {
|
|
788
896
|
startTagInCaption(this, token);
|
|
789
897
|
break;
|
|
790
|
-
|
|
898
|
+
}
|
|
899
|
+
case InsertionMode.IN_COLUMN_GROUP: {
|
|
791
900
|
startTagInColumnGroup(this, token);
|
|
792
901
|
break;
|
|
793
|
-
|
|
902
|
+
}
|
|
903
|
+
case InsertionMode.IN_TABLE_BODY: {
|
|
794
904
|
startTagInTableBody(this, token);
|
|
795
905
|
break;
|
|
796
|
-
|
|
906
|
+
}
|
|
907
|
+
case InsertionMode.IN_ROW: {
|
|
797
908
|
startTagInRow(this, token);
|
|
798
909
|
break;
|
|
799
|
-
|
|
910
|
+
}
|
|
911
|
+
case InsertionMode.IN_CELL: {
|
|
800
912
|
startTagInCell(this, token);
|
|
801
913
|
break;
|
|
802
|
-
|
|
914
|
+
}
|
|
915
|
+
case InsertionMode.IN_SELECT: {
|
|
803
916
|
startTagInSelect(this, token);
|
|
804
917
|
break;
|
|
805
|
-
|
|
918
|
+
}
|
|
919
|
+
case InsertionMode.IN_SELECT_IN_TABLE: {
|
|
806
920
|
startTagInSelectInTable(this, token);
|
|
807
921
|
break;
|
|
808
|
-
|
|
922
|
+
}
|
|
923
|
+
case InsertionMode.IN_TEMPLATE: {
|
|
809
924
|
startTagInTemplate(this, token);
|
|
810
925
|
break;
|
|
811
|
-
|
|
926
|
+
}
|
|
927
|
+
case InsertionMode.AFTER_BODY: {
|
|
812
928
|
startTagAfterBody(this, token);
|
|
813
929
|
break;
|
|
814
|
-
|
|
930
|
+
}
|
|
931
|
+
case InsertionMode.IN_FRAMESET: {
|
|
815
932
|
startTagInFrameset(this, token);
|
|
816
933
|
break;
|
|
817
|
-
|
|
934
|
+
}
|
|
935
|
+
case InsertionMode.AFTER_FRAMESET: {
|
|
818
936
|
startTagAfterFrameset(this, token);
|
|
819
937
|
break;
|
|
820
|
-
|
|
938
|
+
}
|
|
939
|
+
case InsertionMode.AFTER_AFTER_BODY: {
|
|
821
940
|
startTagAfterAfterBody(this, token);
|
|
822
941
|
break;
|
|
823
|
-
|
|
942
|
+
}
|
|
943
|
+
case InsertionMode.AFTER_AFTER_FRAMESET: {
|
|
824
944
|
startTagAfterAfterFrameset(this, token);
|
|
825
945
|
break;
|
|
946
|
+
}
|
|
826
947
|
default:
|
|
827
948
|
// Do nothing
|
|
828
949
|
}
|
|
829
950
|
}
|
|
951
|
+
/** @internal */
|
|
830
952
|
onEndTag(token) {
|
|
831
953
|
this.skipNextNewLine = false;
|
|
832
954
|
this.currentToken = token;
|
|
@@ -837,98 +959,128 @@ export class Parser {
|
|
|
837
959
|
this._endTagOutsideForeignContent(token);
|
|
838
960
|
}
|
|
839
961
|
}
|
|
962
|
+
/** @protected */
|
|
840
963
|
_endTagOutsideForeignContent(token) {
|
|
841
964
|
switch (this.insertionMode) {
|
|
842
|
-
case InsertionMode.INITIAL:
|
|
965
|
+
case InsertionMode.INITIAL: {
|
|
843
966
|
tokenInInitialMode(this, token);
|
|
844
967
|
break;
|
|
845
|
-
|
|
968
|
+
}
|
|
969
|
+
case InsertionMode.BEFORE_HTML: {
|
|
846
970
|
endTagBeforeHtml(this, token);
|
|
847
971
|
break;
|
|
848
|
-
|
|
972
|
+
}
|
|
973
|
+
case InsertionMode.BEFORE_HEAD: {
|
|
849
974
|
endTagBeforeHead(this, token);
|
|
850
975
|
break;
|
|
851
|
-
|
|
976
|
+
}
|
|
977
|
+
case InsertionMode.IN_HEAD: {
|
|
852
978
|
endTagInHead(this, token);
|
|
853
979
|
break;
|
|
854
|
-
|
|
980
|
+
}
|
|
981
|
+
case InsertionMode.IN_HEAD_NO_SCRIPT: {
|
|
855
982
|
endTagInHeadNoScript(this, token);
|
|
856
983
|
break;
|
|
857
|
-
|
|
984
|
+
}
|
|
985
|
+
case InsertionMode.AFTER_HEAD: {
|
|
858
986
|
endTagAfterHead(this, token);
|
|
859
987
|
break;
|
|
860
|
-
|
|
988
|
+
}
|
|
989
|
+
case InsertionMode.IN_BODY: {
|
|
861
990
|
endTagInBody(this, token);
|
|
862
991
|
break;
|
|
863
|
-
|
|
992
|
+
}
|
|
993
|
+
case InsertionMode.TEXT: {
|
|
864
994
|
endTagInText(this, token);
|
|
865
995
|
break;
|
|
866
|
-
|
|
996
|
+
}
|
|
997
|
+
case InsertionMode.IN_TABLE: {
|
|
867
998
|
endTagInTable(this, token);
|
|
868
999
|
break;
|
|
869
|
-
|
|
1000
|
+
}
|
|
1001
|
+
case InsertionMode.IN_TABLE_TEXT: {
|
|
870
1002
|
tokenInTableText(this, token);
|
|
871
1003
|
break;
|
|
872
|
-
|
|
1004
|
+
}
|
|
1005
|
+
case InsertionMode.IN_CAPTION: {
|
|
873
1006
|
endTagInCaption(this, token);
|
|
874
1007
|
break;
|
|
875
|
-
|
|
1008
|
+
}
|
|
1009
|
+
case InsertionMode.IN_COLUMN_GROUP: {
|
|
876
1010
|
endTagInColumnGroup(this, token);
|
|
877
1011
|
break;
|
|
878
|
-
|
|
1012
|
+
}
|
|
1013
|
+
case InsertionMode.IN_TABLE_BODY: {
|
|
879
1014
|
endTagInTableBody(this, token);
|
|
880
1015
|
break;
|
|
881
|
-
|
|
1016
|
+
}
|
|
1017
|
+
case InsertionMode.IN_ROW: {
|
|
882
1018
|
endTagInRow(this, token);
|
|
883
1019
|
break;
|
|
884
|
-
|
|
1020
|
+
}
|
|
1021
|
+
case InsertionMode.IN_CELL: {
|
|
885
1022
|
endTagInCell(this, token);
|
|
886
1023
|
break;
|
|
887
|
-
|
|
1024
|
+
}
|
|
1025
|
+
case InsertionMode.IN_SELECT: {
|
|
888
1026
|
endTagInSelect(this, token);
|
|
889
1027
|
break;
|
|
890
|
-
|
|
1028
|
+
}
|
|
1029
|
+
case InsertionMode.IN_SELECT_IN_TABLE: {
|
|
891
1030
|
endTagInSelectInTable(this, token);
|
|
892
1031
|
break;
|
|
893
|
-
|
|
1032
|
+
}
|
|
1033
|
+
case InsertionMode.IN_TEMPLATE: {
|
|
894
1034
|
endTagInTemplate(this, token);
|
|
895
1035
|
break;
|
|
896
|
-
|
|
1036
|
+
}
|
|
1037
|
+
case InsertionMode.AFTER_BODY: {
|
|
897
1038
|
endTagAfterBody(this, token);
|
|
898
1039
|
break;
|
|
899
|
-
|
|
1040
|
+
}
|
|
1041
|
+
case InsertionMode.IN_FRAMESET: {
|
|
900
1042
|
endTagInFrameset(this, token);
|
|
901
1043
|
break;
|
|
902
|
-
|
|
1044
|
+
}
|
|
1045
|
+
case InsertionMode.AFTER_FRAMESET: {
|
|
903
1046
|
endTagAfterFrameset(this, token);
|
|
904
1047
|
break;
|
|
905
|
-
|
|
1048
|
+
}
|
|
1049
|
+
case InsertionMode.AFTER_AFTER_BODY: {
|
|
906
1050
|
tokenAfterAfterBody(this, token);
|
|
907
1051
|
break;
|
|
1052
|
+
}
|
|
908
1053
|
default:
|
|
909
1054
|
// Do nothing
|
|
910
1055
|
}
|
|
911
1056
|
}
|
|
1057
|
+
/** @internal */
|
|
912
1058
|
onEof(token) {
|
|
913
1059
|
switch (this.insertionMode) {
|
|
914
|
-
case InsertionMode.INITIAL:
|
|
1060
|
+
case InsertionMode.INITIAL: {
|
|
915
1061
|
tokenInInitialMode(this, token);
|
|
916
1062
|
break;
|
|
917
|
-
|
|
1063
|
+
}
|
|
1064
|
+
case InsertionMode.BEFORE_HTML: {
|
|
918
1065
|
tokenBeforeHtml(this, token);
|
|
919
1066
|
break;
|
|
920
|
-
|
|
1067
|
+
}
|
|
1068
|
+
case InsertionMode.BEFORE_HEAD: {
|
|
921
1069
|
tokenBeforeHead(this, token);
|
|
922
1070
|
break;
|
|
923
|
-
|
|
1071
|
+
}
|
|
1072
|
+
case InsertionMode.IN_HEAD: {
|
|
924
1073
|
tokenInHead(this, token);
|
|
925
1074
|
break;
|
|
926
|
-
|
|
1075
|
+
}
|
|
1076
|
+
case InsertionMode.IN_HEAD_NO_SCRIPT: {
|
|
927
1077
|
tokenInHeadNoScript(this, token);
|
|
928
1078
|
break;
|
|
929
|
-
|
|
1079
|
+
}
|
|
1080
|
+
case InsertionMode.AFTER_HEAD: {
|
|
930
1081
|
tokenAfterHead(this, token);
|
|
931
1082
|
break;
|
|
1083
|
+
}
|
|
932
1084
|
case InsertionMode.IN_BODY:
|
|
933
1085
|
case InsertionMode.IN_TABLE:
|
|
934
1086
|
case InsertionMode.IN_CAPTION:
|
|
@@ -937,29 +1089,35 @@ export class Parser {
|
|
|
937
1089
|
case InsertionMode.IN_ROW:
|
|
938
1090
|
case InsertionMode.IN_CELL:
|
|
939
1091
|
case InsertionMode.IN_SELECT:
|
|
940
|
-
case InsertionMode.IN_SELECT_IN_TABLE:
|
|
1092
|
+
case InsertionMode.IN_SELECT_IN_TABLE: {
|
|
941
1093
|
eofInBody(this, token);
|
|
942
1094
|
break;
|
|
943
|
-
|
|
1095
|
+
}
|
|
1096
|
+
case InsertionMode.TEXT: {
|
|
944
1097
|
eofInText(this, token);
|
|
945
1098
|
break;
|
|
946
|
-
|
|
1099
|
+
}
|
|
1100
|
+
case InsertionMode.IN_TABLE_TEXT: {
|
|
947
1101
|
tokenInTableText(this, token);
|
|
948
1102
|
break;
|
|
949
|
-
|
|
1103
|
+
}
|
|
1104
|
+
case InsertionMode.IN_TEMPLATE: {
|
|
950
1105
|
eofInTemplate(this, token);
|
|
951
1106
|
break;
|
|
1107
|
+
}
|
|
952
1108
|
case InsertionMode.AFTER_BODY:
|
|
953
1109
|
case InsertionMode.IN_FRAMESET:
|
|
954
1110
|
case InsertionMode.AFTER_FRAMESET:
|
|
955
1111
|
case InsertionMode.AFTER_AFTER_BODY:
|
|
956
|
-
case InsertionMode.AFTER_AFTER_FRAMESET:
|
|
1112
|
+
case InsertionMode.AFTER_AFTER_FRAMESET: {
|
|
957
1113
|
stopParsing(this, token);
|
|
958
1114
|
break;
|
|
1115
|
+
}
|
|
959
1116
|
default:
|
|
960
1117
|
// Do nothing
|
|
961
1118
|
}
|
|
962
1119
|
}
|
|
1120
|
+
/** @internal */
|
|
963
1121
|
onWhitespaceCharacter(token) {
|
|
964
1122
|
if (this.skipNextNewLine) {
|
|
965
1123
|
this.skipNextNewLine = false;
|
|
@@ -983,26 +1141,30 @@ export class Parser {
|
|
|
983
1141
|
case InsertionMode.IN_SELECT:
|
|
984
1142
|
case InsertionMode.IN_SELECT_IN_TABLE:
|
|
985
1143
|
case InsertionMode.IN_FRAMESET:
|
|
986
|
-
case InsertionMode.AFTER_FRAMESET:
|
|
1144
|
+
case InsertionMode.AFTER_FRAMESET: {
|
|
987
1145
|
this._insertCharacters(token);
|
|
988
1146
|
break;
|
|
1147
|
+
}
|
|
989
1148
|
case InsertionMode.IN_BODY:
|
|
990
1149
|
case InsertionMode.IN_CAPTION:
|
|
991
1150
|
case InsertionMode.IN_CELL:
|
|
992
1151
|
case InsertionMode.IN_TEMPLATE:
|
|
993
1152
|
case InsertionMode.AFTER_BODY:
|
|
994
1153
|
case InsertionMode.AFTER_AFTER_BODY:
|
|
995
|
-
case InsertionMode.AFTER_AFTER_FRAMESET:
|
|
1154
|
+
case InsertionMode.AFTER_AFTER_FRAMESET: {
|
|
996
1155
|
whitespaceCharacterInBody(this, token);
|
|
997
1156
|
break;
|
|
1157
|
+
}
|
|
998
1158
|
case InsertionMode.IN_TABLE:
|
|
999
1159
|
case InsertionMode.IN_TABLE_BODY:
|
|
1000
|
-
case InsertionMode.IN_ROW:
|
|
1160
|
+
case InsertionMode.IN_ROW: {
|
|
1001
1161
|
characterInTable(this, token);
|
|
1002
1162
|
break;
|
|
1003
|
-
|
|
1163
|
+
}
|
|
1164
|
+
case InsertionMode.IN_TABLE_TEXT: {
|
|
1004
1165
|
whitespaceCharacterInTableText(this, token);
|
|
1005
1166
|
break;
|
|
1167
|
+
}
|
|
1006
1168
|
default:
|
|
1007
1169
|
// Do nothing
|
|
1008
1170
|
}
|
|
@@ -1528,7 +1690,7 @@ function numberedHeaderStartTagInBody(p, token) {
|
|
|
1528
1690
|
if (p.openElements.hasInButtonScope($.P)) {
|
|
1529
1691
|
p._closePElement();
|
|
1530
1692
|
}
|
|
1531
|
-
if (
|
|
1693
|
+
if (NUMBERED_HEADERS.has(p.openElements.currentTagId)) {
|
|
1532
1694
|
p.openElements.pop();
|
|
1533
1695
|
}
|
|
1534
1696
|
p._insertElement(token, NS.HTML);
|
|
@@ -1690,9 +1852,9 @@ function iframeStartTagInBody(p, token) {
|
|
|
1690
1852
|
p.framesetOk = false;
|
|
1691
1853
|
p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
|
|
1692
1854
|
}
|
|
1693
|
-
//NOTE: here we assume that we always act as
|
|
1694
|
-
//<noembed> as rawtext.
|
|
1695
|
-
function
|
|
1855
|
+
//NOTE: here we assume that we always act as a user agent with enabled plugins/frames, so we parse
|
|
1856
|
+
//<noembed>/<noframes> as rawtext.
|
|
1857
|
+
function rawTextStartTagInBody(p, token) {
|
|
1696
1858
|
p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
|
|
1697
1859
|
}
|
|
1698
1860
|
function selectStartTagInBody(p, token) {
|
|
@@ -1804,6 +1966,7 @@ function startTagInBody(p, token) {
|
|
|
1804
1966
|
case $.DETAILS:
|
|
1805
1967
|
case $.ADDRESS:
|
|
1806
1968
|
case $.ARTICLE:
|
|
1969
|
+
case $.SEARCH:
|
|
1807
1970
|
case $.SECTION:
|
|
1808
1971
|
case $.SUMMARY:
|
|
1809
1972
|
case $.FIELDSET:
|
|
@@ -1927,8 +2090,9 @@ function startTagInBody(p, token) {
|
|
|
1927
2090
|
optgroupStartTagInBody(p, token);
|
|
1928
2091
|
break;
|
|
1929
2092
|
}
|
|
1930
|
-
case $.NOEMBED:
|
|
1931
|
-
|
|
2093
|
+
case $.NOEMBED:
|
|
2094
|
+
case $.NOFRAMES: {
|
|
2095
|
+
rawTextStartTagInBody(p, token);
|
|
1932
2096
|
break;
|
|
1933
2097
|
}
|
|
1934
2098
|
case $.FRAMESET: {
|
|
@@ -1941,7 +2105,7 @@ function startTagInBody(p, token) {
|
|
|
1941
2105
|
}
|
|
1942
2106
|
case $.NOSCRIPT: {
|
|
1943
2107
|
if (p.options.scriptingEnabled) {
|
|
1944
|
-
|
|
2108
|
+
rawTextStartTagInBody(p, token);
|
|
1945
2109
|
}
|
|
1946
2110
|
else {
|
|
1947
2111
|
genericStartTagInBody(p, token);
|
|
@@ -2113,6 +2277,7 @@ function endTagInBody(p, token) {
|
|
|
2113
2277
|
case $.ADDRESS:
|
|
2114
2278
|
case $.ARTICLE:
|
|
2115
2279
|
case $.DETAILS:
|
|
2280
|
+
case $.SEARCH:
|
|
2116
2281
|
case $.SECTION:
|
|
2117
2282
|
case $.SUMMARY:
|
|
2118
2283
|
case $.LISTING:
|
|
@@ -2632,8 +2797,9 @@ function endTagInRow(p, token) {
|
|
|
2632
2797
|
// Ignore end tag
|
|
2633
2798
|
break;
|
|
2634
2799
|
}
|
|
2635
|
-
default:
|
|
2800
|
+
default: {
|
|
2636
2801
|
endTagInTable(p, token);
|
|
2802
|
+
}
|
|
2637
2803
|
}
|
|
2638
2804
|
}
|
|
2639
2805
|
// The "in cell" insertion mode
|
|
@@ -2712,6 +2878,17 @@ function startTagInSelect(p, token) {
|
|
|
2712
2878
|
p._insertElement(token, NS.HTML);
|
|
2713
2879
|
break;
|
|
2714
2880
|
}
|
|
2881
|
+
case $.HR: {
|
|
2882
|
+
if (p.openElements.currentTagId === $.OPTION) {
|
|
2883
|
+
p.openElements.pop();
|
|
2884
|
+
}
|
|
2885
|
+
if (p.openElements.currentTagId === $.OPTGROUP) {
|
|
2886
|
+
p.openElements.pop();
|
|
2887
|
+
}
|
|
2888
|
+
p._appendElement(token, NS.HTML);
|
|
2889
|
+
token.ackSelfClosing = true;
|
|
2890
|
+
break;
|
|
2891
|
+
}
|
|
2715
2892
|
case $.INPUT:
|
|
2716
2893
|
case $.KEYGEN:
|
|
2717
2894
|
case $.TEXTAREA:
|
|
@@ -2822,39 +2999,45 @@ function startTagInTemplate(p, token) {
|
|
|
2822
2999
|
case $.SCRIPT:
|
|
2823
3000
|
case $.STYLE:
|
|
2824
3001
|
case $.TEMPLATE:
|
|
2825
|
-
case $.TITLE:
|
|
3002
|
+
case $.TITLE: {
|
|
2826
3003
|
startTagInHead(p, token);
|
|
2827
3004
|
break;
|
|
3005
|
+
}
|
|
2828
3006
|
// Re-process the token in the appropriate mode
|
|
2829
3007
|
case $.CAPTION:
|
|
2830
3008
|
case $.COLGROUP:
|
|
2831
3009
|
case $.TBODY:
|
|
2832
3010
|
case $.TFOOT:
|
|
2833
|
-
case $.THEAD:
|
|
3011
|
+
case $.THEAD: {
|
|
2834
3012
|
p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE;
|
|
2835
3013
|
p.insertionMode = InsertionMode.IN_TABLE;
|
|
2836
3014
|
startTagInTable(p, token);
|
|
2837
3015
|
break;
|
|
2838
|
-
|
|
3016
|
+
}
|
|
3017
|
+
case $.COL: {
|
|
2839
3018
|
p.tmplInsertionModeStack[0] = InsertionMode.IN_COLUMN_GROUP;
|
|
2840
3019
|
p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
|
|
2841
3020
|
startTagInColumnGroup(p, token);
|
|
2842
3021
|
break;
|
|
2843
|
-
|
|
3022
|
+
}
|
|
3023
|
+
case $.TR: {
|
|
2844
3024
|
p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE_BODY;
|
|
2845
3025
|
p.insertionMode = InsertionMode.IN_TABLE_BODY;
|
|
2846
3026
|
startTagInTableBody(p, token);
|
|
2847
3027
|
break;
|
|
3028
|
+
}
|
|
2848
3029
|
case $.TD:
|
|
2849
|
-
case $.TH:
|
|
3030
|
+
case $.TH: {
|
|
2850
3031
|
p.tmplInsertionModeStack[0] = InsertionMode.IN_ROW;
|
|
2851
3032
|
p.insertionMode = InsertionMode.IN_ROW;
|
|
2852
3033
|
startTagInRow(p, token);
|
|
2853
3034
|
break;
|
|
2854
|
-
|
|
3035
|
+
}
|
|
3036
|
+
default: {
|
|
2855
3037
|
p.tmplInsertionModeStack[0] = InsertionMode.IN_BODY;
|
|
2856
3038
|
p.insertionMode = InsertionMode.IN_BODY;
|
|
2857
3039
|
startTagInBody(p, token);
|
|
3040
|
+
}
|
|
2858
3041
|
}
|
|
2859
3042
|
}
|
|
2860
3043
|
function endTagInTemplate(p, token) {
|
|
@@ -3055,4 +3238,3 @@ function endTagInForeignContent(p, token) {
|
|
|
3055
3238
|
}
|
|
3056
3239
|
}
|
|
3057
3240
|
}
|
|
3058
|
-
//# sourceMappingURL=index.js.map
|