diff --git a/package-lock.json b/package-lock.json index f95e218eb..598b493d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@typescript-eslint/parser": "^5.41.0", "eslint": "^8.26.0", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-unicorn": "^43.0.2", + "eslint-plugin-unicorn": "^44.0.2", "husky": "^8.0.1", "jest": "^28.1.3", "lint-staged": "^13.0.3", @@ -279,9 +279,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz", - "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true, "engines": { "node": ">=6.9.0" @@ -1833,9 +1833,9 @@ "dev": true }, "node_modules/builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true, "engines": { "node": ">=6" @@ -1904,9 +1904,9 @@ } }, "node_modules/ci-info": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz", - "integrity": "sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.5.0.tgz", + "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==", "dev": true }, "node_modules/cjs-module-lexer": { @@ -2411,18 +2411,18 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "43.0.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.2.tgz", - "integrity": "sha512-DtqZ5mf/GMlfWoz1abIjq5jZfaFuHzGBZYIeuJfEoKKGWRHr2JiJR+ea+BF7Wx2N1PPRoT/2fwgiK1NnmNE3Hg==", + "version": "44.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-44.0.2.tgz", + "integrity": "sha512-GLIDX1wmeEqpGaKcnMcqRvMVsoabeF0Ton0EX4Th5u6Kmf7RM9WBl705AXFEsns56ESkEs0uyelLuUTvz9Tr0w==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "ci-info": "^3.3.2", + "@babel/helper-validator-identifier": "^7.19.1", + "ci-info": "^3.4.0", "clean-regexp": "^1.0.0", "eslint-utils": "^3.0.0", "esquery": "^1.4.0", "indent-string": "^4.0.0", - "is-builtin-module": "^3.1.0", + "is-builtin-module": "^3.2.0", "lodash": "^4.17.21", "pluralize": "^8.0.0", "read-pkg-up": "^7.0.1", @@ -2438,7 +2438,7 @@ "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" }, "peerDependencies": { - "eslint": ">=8.18.0" + "eslint": ">=8.23.1" } }, "node_modules/eslint-scope": { @@ -3130,15 +3130,18 @@ "dev": true }, "node_modules/is-builtin-module": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.1.0.tgz", - "integrity": "sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.0.tgz", + "integrity": "sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==", "dev": true, "dependencies": { - "builtin-modules": "^3.0.0" + "builtin-modules": "^3.3.0" }, "engines": { "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/is-core-module": { @@ -6261,9 +6264,9 @@ } }, "@babel/helper-validator-identifier": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz", - "integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true }, "@babel/helper-validator-option": { @@ -7451,9 +7454,9 @@ "dev": true }, "builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true }, "callsites": { @@ -7491,9 +7494,9 @@ "dev": true }, "ci-info": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz", - "integrity": "sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.5.0.tgz", + "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==", "dev": true }, "cjs-module-lexer": { @@ -7887,18 +7890,18 @@ "requires": {} }, "eslint-plugin-unicorn": { - "version": "43.0.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.2.tgz", - "integrity": "sha512-DtqZ5mf/GMlfWoz1abIjq5jZfaFuHzGBZYIeuJfEoKKGWRHr2JiJR+ea+BF7Wx2N1PPRoT/2fwgiK1NnmNE3Hg==", + "version": "44.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-44.0.2.tgz", + "integrity": "sha512-GLIDX1wmeEqpGaKcnMcqRvMVsoabeF0Ton0EX4Th5u6Kmf7RM9WBl705AXFEsns56ESkEs0uyelLuUTvz9Tr0w==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.18.6", - "ci-info": "^3.3.2", + "@babel/helper-validator-identifier": "^7.19.1", + "ci-info": "^3.4.0", "clean-regexp": "^1.0.0", "eslint-utils": "^3.0.0", "esquery": "^1.4.0", "indent-string": "^4.0.0", - "is-builtin-module": "^3.1.0", + "is-builtin-module": "^3.2.0", "lodash": "^4.17.21", "pluralize": "^8.0.0", "read-pkg-up": "^7.0.1", @@ -8355,12 +8358,12 @@ "dev": true }, "is-builtin-module": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.1.0.tgz", - "integrity": "sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.0.tgz", + "integrity": "sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==", "dev": true, "requires": { - "builtin-modules": "^3.0.0" + "builtin-modules": "^3.3.0" } }, "is-core-module": { diff --git a/package.json b/package.json index d1d04109f..8b9cef0ac 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@typescript-eslint/parser": "^5.41.0", "eslint": "^8.26.0", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-unicorn": "^43.0.2", + "eslint-plugin-unicorn": "^44.0.2", "husky": "^8.0.1", "jest": "^28.1.3", "lint-staged": "^13.0.3", diff --git a/packages/parse5/lib/parser/index.ts b/packages/parse5/lib/parser/index.ts index 1b97d833c..ec2c32988 100644 --- a/packages/parse5/lib/parser/index.ts +++ b/packages/parse5/lib/parser/index.ts @@ -623,51 +623,63 @@ export class Parser implements TokenHandler, Stack for (let i = this.openElements.stackTop; i >= 0; i--) { //Insertion mode reset map switch (i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i]) { - case $.TR: + case $.TR: { this.insertionMode = InsertionMode.IN_ROW; return; + } case $.TBODY: case $.THEAD: - case $.TFOOT: + case $.TFOOT: { this.insertionMode = InsertionMode.IN_TABLE_BODY; return; - case $.CAPTION: + } + case $.CAPTION: { this.insertionMode = InsertionMode.IN_CAPTION; return; - case $.COLGROUP: + } + case $.COLGROUP: { this.insertionMode = InsertionMode.IN_COLUMN_GROUP; return; - case $.TABLE: + } + case $.TABLE: { this.insertionMode = InsertionMode.IN_TABLE; return; - case $.BODY: + } + case $.BODY: { this.insertionMode = InsertionMode.IN_BODY; return; - case $.FRAMESET: + } + case $.FRAMESET: { this.insertionMode = InsertionMode.IN_FRAMESET; return; - case $.SELECT: + } + case $.SELECT: { this._resetInsertionModeForSelect(i); return; - case $.TEMPLATE: + } + case $.TEMPLATE: { this.insertionMode = this.tmplInsertionModeStack[0]; return; - case $.HTML: + } + case $.HTML: { this.insertionMode = this.headElement ? InsertionMode.AFTER_HEAD : InsertionMode.BEFORE_HEAD; return; + } case $.TD: - case $.TH: + case $.TH: { if (i > 0) { this.insertionMode = InsertionMode.IN_CELL; return; } break; - case $.HEAD: + } + case $.HEAD: { if (i > 0) { this.insertionMode = InsertionMode.IN_HEAD; return; } break; + } } } @@ -705,11 +717,12 @@ export class Parser implements TokenHandler, Stack const openElement = this.openElements.items[i]; switch (this.openElements.tagIDs[i]) { - case $.TEMPLATE: + case $.TEMPLATE: { if (this.treeAdapter.getNamespaceURI(openElement) === NS.HTML) { return { parent: this.treeAdapter.getTemplateContent(openElement), beforeElement: null }; } break; + } case $.TABLE: { const parent = this.treeAdapter.getParentNode(openElement); @@ -753,52 +766,65 @@ export class Parser implements TokenHandler, Stack } switch (this.insertionMode) { - case InsertionMode.INITIAL: + case InsertionMode.INITIAL: { tokenInInitialMode(this, token); break; - case InsertionMode.BEFORE_HTML: + } + case InsertionMode.BEFORE_HTML: { tokenBeforeHtml(this, token); break; - case InsertionMode.BEFORE_HEAD: + } + case InsertionMode.BEFORE_HEAD: { tokenBeforeHead(this, token); break; - case InsertionMode.IN_HEAD: + } + case InsertionMode.IN_HEAD: { tokenInHead(this, token); break; - case InsertionMode.IN_HEAD_NO_SCRIPT: + } + case InsertionMode.IN_HEAD_NO_SCRIPT: { tokenInHeadNoScript(this, token); break; - case InsertionMode.AFTER_HEAD: + } + case InsertionMode.AFTER_HEAD: { tokenAfterHead(this, token); break; + } case InsertionMode.IN_BODY: case InsertionMode.IN_CAPTION: case InsertionMode.IN_CELL: - case InsertionMode.IN_TEMPLATE: + case InsertionMode.IN_TEMPLATE: { characterInBody(this, token); break; + } case InsertionMode.TEXT: case InsertionMode.IN_SELECT: - case InsertionMode.IN_SELECT_IN_TABLE: + case InsertionMode.IN_SELECT_IN_TABLE: { this._insertCharacters(token); break; + } case InsertionMode.IN_TABLE: case InsertionMode.IN_TABLE_BODY: - case InsertionMode.IN_ROW: + case InsertionMode.IN_ROW: { characterInTable(this, token); break; - case InsertionMode.IN_TABLE_TEXT: + } + case InsertionMode.IN_TABLE_TEXT: { characterInTableText(this, token); break; - case InsertionMode.IN_COLUMN_GROUP: + } + case InsertionMode.IN_COLUMN_GROUP: { tokenInColumnGroup(this, token); break; - case InsertionMode.AFTER_BODY: + } + case InsertionMode.AFTER_BODY: { tokenAfterBody(this, token); break; - case InsertionMode.AFTER_AFTER_BODY: + } + case InsertionMode.AFTER_AFTER_BODY: { tokenAfterAfterBody(this, token); break; + } default: // Do nothing } @@ -812,41 +838,52 @@ export class Parser implements TokenHandler, Stack } switch (this.insertionMode) { - case InsertionMode.INITIAL: + case InsertionMode.INITIAL: { tokenInInitialMode(this, token); break; - case InsertionMode.BEFORE_HTML: + } + case InsertionMode.BEFORE_HTML: { tokenBeforeHtml(this, token); break; - case InsertionMode.BEFORE_HEAD: + } + case InsertionMode.BEFORE_HEAD: { tokenBeforeHead(this, token); break; - case InsertionMode.IN_HEAD: + } + case InsertionMode.IN_HEAD: { tokenInHead(this, token); break; - case InsertionMode.IN_HEAD_NO_SCRIPT: + } + case InsertionMode.IN_HEAD_NO_SCRIPT: { tokenInHeadNoScript(this, token); break; - case InsertionMode.AFTER_HEAD: + } + case InsertionMode.AFTER_HEAD: { tokenAfterHead(this, token); break; - case InsertionMode.TEXT: + } + case InsertionMode.TEXT: { this._insertCharacters(token); break; + } case InsertionMode.IN_TABLE: case InsertionMode.IN_TABLE_BODY: - case InsertionMode.IN_ROW: + case InsertionMode.IN_ROW: { characterInTable(this, token); break; - case InsertionMode.IN_COLUMN_GROUP: + } + case InsertionMode.IN_COLUMN_GROUP: { tokenInColumnGroup(this, token); break; - case InsertionMode.AFTER_BODY: + } + case InsertionMode.AFTER_BODY: { tokenAfterBody(this, token); break; - case InsertionMode.AFTER_AFTER_BODY: + } + case InsertionMode.AFTER_AFTER_BODY: { tokenAfterAfterBody(this, token); break; + } default: // Do nothing } @@ -877,19 +914,23 @@ export class Parser implements TokenHandler, Stack case InsertionMode.IN_SELECT_IN_TABLE: case InsertionMode.IN_TEMPLATE: case InsertionMode.IN_FRAMESET: - case InsertionMode.AFTER_FRAMESET: + case InsertionMode.AFTER_FRAMESET: { appendComment(this, token); break; - case InsertionMode.IN_TABLE_TEXT: + } + case InsertionMode.IN_TABLE_TEXT: { tokenInTableText(this, token); break; - case InsertionMode.AFTER_BODY: + } + case InsertionMode.AFTER_BODY: { appendCommentToRootHtmlElement(this, token); break; + } case InsertionMode.AFTER_AFTER_BODY: - case InsertionMode.AFTER_AFTER_FRAMESET: + case InsertionMode.AFTER_AFTER_FRAMESET: { appendCommentToDocument(this, token); break; + } default: // Do nothing } @@ -897,18 +938,21 @@ export class Parser implements TokenHandler, Stack onDoctype(token: DoctypeToken): void { this.skipNextNewLine = false; switch (this.insertionMode) { - case InsertionMode.INITIAL: + case InsertionMode.INITIAL: { doctypeInInitialMode(this, token); break; + } case InsertionMode.BEFORE_HEAD: case InsertionMode.IN_HEAD: case InsertionMode.IN_HEAD_NO_SCRIPT: - case InsertionMode.AFTER_HEAD: + case InsertionMode.AFTER_HEAD: { this._err(token, ERR.misplacedDoctype); break; - case InsertionMode.IN_TABLE_TEXT: + } + case InsertionMode.IN_TABLE_TEXT: { tokenInTableText(this, token); break; + } default: // Do nothing } @@ -942,72 +986,94 @@ export class Parser implements TokenHandler, Stack } _startTagOutsideForeignContent(token: TagToken): void { switch (this.insertionMode) { - case InsertionMode.INITIAL: + case InsertionMode.INITIAL: { tokenInInitialMode(this, token); break; - case InsertionMode.BEFORE_HTML: + } + case InsertionMode.BEFORE_HTML: { startTagBeforeHtml(this, token); break; - case InsertionMode.BEFORE_HEAD: + } + case InsertionMode.BEFORE_HEAD: { startTagBeforeHead(this, token); break; - case InsertionMode.IN_HEAD: + } + case InsertionMode.IN_HEAD: { startTagInHead(this, token); break; - case InsertionMode.IN_HEAD_NO_SCRIPT: + } + case InsertionMode.IN_HEAD_NO_SCRIPT: { startTagInHeadNoScript(this, token); break; - case InsertionMode.AFTER_HEAD: + } + case InsertionMode.AFTER_HEAD: { startTagAfterHead(this, token); break; - case InsertionMode.IN_BODY: + } + case InsertionMode.IN_BODY: { startTagInBody(this, token); break; - case InsertionMode.IN_TABLE: + } + case InsertionMode.IN_TABLE: { startTagInTable(this, token); break; - case InsertionMode.IN_TABLE_TEXT: + } + case InsertionMode.IN_TABLE_TEXT: { tokenInTableText(this, token); break; - case InsertionMode.IN_CAPTION: + } + case InsertionMode.IN_CAPTION: { startTagInCaption(this, token); break; - case InsertionMode.IN_COLUMN_GROUP: + } + case InsertionMode.IN_COLUMN_GROUP: { startTagInColumnGroup(this, token); break; - case InsertionMode.IN_TABLE_BODY: + } + case InsertionMode.IN_TABLE_BODY: { startTagInTableBody(this, token); break; - case InsertionMode.IN_ROW: + } + case InsertionMode.IN_ROW: { startTagInRow(this, token); break; - case InsertionMode.IN_CELL: + } + case InsertionMode.IN_CELL: { startTagInCell(this, token); break; - case InsertionMode.IN_SELECT: + } + case InsertionMode.IN_SELECT: { startTagInSelect(this, token); break; - case InsertionMode.IN_SELECT_IN_TABLE: + } + case InsertionMode.IN_SELECT_IN_TABLE: { startTagInSelectInTable(this, token); break; - case InsertionMode.IN_TEMPLATE: + } + case InsertionMode.IN_TEMPLATE: { startTagInTemplate(this, token); break; - case InsertionMode.AFTER_BODY: + } + case InsertionMode.AFTER_BODY: { startTagAfterBody(this, token); break; - case InsertionMode.IN_FRAMESET: + } + case InsertionMode.IN_FRAMESET: { startTagInFrameset(this, token); break; - case InsertionMode.AFTER_FRAMESET: + } + case InsertionMode.AFTER_FRAMESET: { startTagAfterFrameset(this, token); break; - case InsertionMode.AFTER_AFTER_BODY: + } + case InsertionMode.AFTER_AFTER_BODY: { startTagAfterAfterBody(this, token); break; - case InsertionMode.AFTER_AFTER_FRAMESET: + } + case InsertionMode.AFTER_AFTER_FRAMESET: { startTagAfterAfterFrameset(this, token); break; + } default: // Do nothing } @@ -1024,96 +1090,124 @@ export class Parser implements TokenHandler, Stack } _endTagOutsideForeignContent(token: TagToken): void { switch (this.insertionMode) { - case InsertionMode.INITIAL: + case InsertionMode.INITIAL: { tokenInInitialMode(this, token); break; - case InsertionMode.BEFORE_HTML: + } + case InsertionMode.BEFORE_HTML: { endTagBeforeHtml(this, token); break; - case InsertionMode.BEFORE_HEAD: + } + case InsertionMode.BEFORE_HEAD: { endTagBeforeHead(this, token); break; - case InsertionMode.IN_HEAD: + } + case InsertionMode.IN_HEAD: { endTagInHead(this, token); break; - case InsertionMode.IN_HEAD_NO_SCRIPT: + } + case InsertionMode.IN_HEAD_NO_SCRIPT: { endTagInHeadNoScript(this, token); break; - case InsertionMode.AFTER_HEAD: + } + case InsertionMode.AFTER_HEAD: { endTagAfterHead(this, token); break; - case InsertionMode.IN_BODY: + } + case InsertionMode.IN_BODY: { endTagInBody(this, token); break; - case InsertionMode.TEXT: + } + case InsertionMode.TEXT: { endTagInText(this, token); break; - case InsertionMode.IN_TABLE: + } + case InsertionMode.IN_TABLE: { endTagInTable(this, token); break; - case InsertionMode.IN_TABLE_TEXT: + } + case InsertionMode.IN_TABLE_TEXT: { tokenInTableText(this, token); break; - case InsertionMode.IN_CAPTION: + } + case InsertionMode.IN_CAPTION: { endTagInCaption(this, token); break; - case InsertionMode.IN_COLUMN_GROUP: + } + case InsertionMode.IN_COLUMN_GROUP: { endTagInColumnGroup(this, token); break; - case InsertionMode.IN_TABLE_BODY: + } + case InsertionMode.IN_TABLE_BODY: { endTagInTableBody(this, token); break; - case InsertionMode.IN_ROW: + } + case InsertionMode.IN_ROW: { endTagInRow(this, token); break; - case InsertionMode.IN_CELL: + } + case InsertionMode.IN_CELL: { endTagInCell(this, token); break; - case InsertionMode.IN_SELECT: + } + case InsertionMode.IN_SELECT: { endTagInSelect(this, token); break; - case InsertionMode.IN_SELECT_IN_TABLE: + } + case InsertionMode.IN_SELECT_IN_TABLE: { endTagInSelectInTable(this, token); break; - case InsertionMode.IN_TEMPLATE: + } + case InsertionMode.IN_TEMPLATE: { endTagInTemplate(this, token); break; - case InsertionMode.AFTER_BODY: + } + case InsertionMode.AFTER_BODY: { endTagAfterBody(this, token); break; - case InsertionMode.IN_FRAMESET: + } + case InsertionMode.IN_FRAMESET: { endTagInFrameset(this, token); break; - case InsertionMode.AFTER_FRAMESET: + } + case InsertionMode.AFTER_FRAMESET: { endTagAfterFrameset(this, token); break; - case InsertionMode.AFTER_AFTER_BODY: + } + case InsertionMode.AFTER_AFTER_BODY: { tokenAfterAfterBody(this, token); break; + } default: // Do nothing } } onEof(token: EOFToken): void { switch (this.insertionMode) { - case InsertionMode.INITIAL: + case InsertionMode.INITIAL: { tokenInInitialMode(this, token); break; - case InsertionMode.BEFORE_HTML: + } + case InsertionMode.BEFORE_HTML: { tokenBeforeHtml(this, token); break; - case InsertionMode.BEFORE_HEAD: + } + case InsertionMode.BEFORE_HEAD: { tokenBeforeHead(this, token); break; - case InsertionMode.IN_HEAD: + } + case InsertionMode.IN_HEAD: { tokenInHead(this, token); break; - case InsertionMode.IN_HEAD_NO_SCRIPT: + } + case InsertionMode.IN_HEAD_NO_SCRIPT: { tokenInHeadNoScript(this, token); break; - case InsertionMode.AFTER_HEAD: + } + case InsertionMode.AFTER_HEAD: { tokenAfterHead(this, token); break; + } case InsertionMode.IN_BODY: case InsertionMode.IN_TABLE: case InsertionMode.IN_CAPTION: @@ -1122,25 +1216,30 @@ export class Parser implements TokenHandler, Stack case InsertionMode.IN_ROW: case InsertionMode.IN_CELL: case InsertionMode.IN_SELECT: - case InsertionMode.IN_SELECT_IN_TABLE: + case InsertionMode.IN_SELECT_IN_TABLE: { eofInBody(this, token); break; - case InsertionMode.TEXT: + } + case InsertionMode.TEXT: { eofInText(this, token); break; - case InsertionMode.IN_TABLE_TEXT: + } + case InsertionMode.IN_TABLE_TEXT: { tokenInTableText(this, token); break; - case InsertionMode.IN_TEMPLATE: + } + case InsertionMode.IN_TEMPLATE: { eofInTemplate(this, token); break; + } case InsertionMode.AFTER_BODY: case InsertionMode.IN_FRAMESET: case InsertionMode.AFTER_FRAMESET: case InsertionMode.AFTER_AFTER_BODY: - case InsertionMode.AFTER_AFTER_FRAMESET: + case InsertionMode.AFTER_AFTER_FRAMESET: { stopParsing(this, token); break; + } default: // Do nothing } @@ -1172,26 +1271,30 @@ export class Parser implements TokenHandler, Stack case InsertionMode.IN_SELECT: case InsertionMode.IN_SELECT_IN_TABLE: case InsertionMode.IN_FRAMESET: - case InsertionMode.AFTER_FRAMESET: + case InsertionMode.AFTER_FRAMESET: { this._insertCharacters(token); break; + } case InsertionMode.IN_BODY: case InsertionMode.IN_CAPTION: case InsertionMode.IN_CELL: case InsertionMode.IN_TEMPLATE: case InsertionMode.AFTER_BODY: case InsertionMode.AFTER_AFTER_BODY: - case InsertionMode.AFTER_AFTER_FRAMESET: + case InsertionMode.AFTER_AFTER_FRAMESET: { whitespaceCharacterInBody(this, token); break; + } case InsertionMode.IN_TABLE: case InsertionMode.IN_TABLE_BODY: - case InsertionMode.IN_ROW: + case InsertionMode.IN_ROW: { characterInTable(this, token); break; - case InsertionMode.IN_TABLE_TEXT: + } + case InsertionMode.IN_TABLE_TEXT: { whitespaceCharacterInTableText(this, token); break; + } default: // Do nothing } @@ -3031,8 +3134,9 @@ function endTagInRow(p: Parser, token: TagToken // Ignore end tag break; } - default: + default: { endTagInTable(p, token); + } } } @@ -3240,40 +3344,46 @@ function startTagInTemplate(p: Parser, token: T case $.SCRIPT: case $.STYLE: case $.TEMPLATE: - case $.TITLE: + case $.TITLE: { startTagInHead(p, token); break; + } // Re-process the token in the appropriate mode case $.CAPTION: case $.COLGROUP: case $.TBODY: case $.TFOOT: - case $.THEAD: + case $.THEAD: { p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE; p.insertionMode = InsertionMode.IN_TABLE; startTagInTable(p, token); break; - case $.COL: + } + case $.COL: { p.tmplInsertionModeStack[0] = InsertionMode.IN_COLUMN_GROUP; p.insertionMode = InsertionMode.IN_COLUMN_GROUP; startTagInColumnGroup(p, token); break; - case $.TR: + } + case $.TR: { p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE_BODY; p.insertionMode = InsertionMode.IN_TABLE_BODY; startTagInTableBody(p, token); break; + } case $.TD: - case $.TH: + case $.TH: { p.tmplInsertionModeStack[0] = InsertionMode.IN_ROW; p.insertionMode = InsertionMode.IN_ROW; startTagInRow(p, token); break; - default: + } + default: { p.tmplInsertionModeStack[0] = InsertionMode.IN_BODY; p.insertionMode = InsertionMode.IN_BODY; startTagInBody(p, token); + } } } diff --git a/packages/parse5/lib/tokenizer/index.ts b/packages/parse5/lib/tokenizer/index.ts index d320a97fd..3cfbff196 100644 --- a/packages/parse5/lib/tokenizer/index.ts +++ b/packages/parse5/lib/tokenizer/index.ts @@ -2423,7 +2423,7 @@ export class Tokenizer { this._emitEOFToken(); break; } - default: + default: { if (this._consumeSequenceIfMatch($$.PUBLIC, false)) { this.state = State.AFTER_DOCTYPE_PUBLIC_KEYWORD; } else if (this._consumeSequenceIfMatch($$.SYSTEM, false)) { @@ -2437,6 +2437,7 @@ export class Tokenizer { this.state = State.BOGUS_DOCTYPE; this._stateBogusDoctype(cp); } + } } } diff --git a/test/utils/serialize-to-dat-file-format.ts b/test/utils/serialize-to-dat-file-format.ts index c6bb23a45..05ca8b1a4 100644 --- a/test/utils/serialize-to-dat-file-format.ts +++ b/test/utils/serialize-to-dat-file-format.ts @@ -9,12 +9,15 @@ function getElementSerializedNamespaceURI( treeAdapter: TreeAdapter ): string { switch (treeAdapter.getNamespaceURI(element)) { - case html.NS.SVG: + case html.NS.SVG: { return 'svg '; - case html.NS.MATHML: + } + case html.NS.MATHML: { return 'math '; - default: + } + default: { return ''; + } } }