diff --git a/changelog_unreleased/html/13578.md b/changelog_unreleased/html/13578.md new file mode 100644 index 000000000..9875c27ec --- /dev/null +++ b/changelog_unreleased/html/13578.md @@ -0,0 +1,3 @@ +#### Update angular-html-parser (#13578 by @thorn0) + +Prettier's fork of Angular's HTML parser was synced with the upstream. diff --git a/package.json b/package.json index e88676ea8..dd5238f7b 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "acorn": "8.8.0", "acorn-jsx": "5.3.2", "angular-estree-parser": "2.5.1", - "angular-html-parser": "1.8.0", + "angular-html-parser": "2.0.0", "camelcase": "7.0.0", "chalk": "5.0.1", "ci-info": "3.4.0", diff --git a/src/language-html/clean.js b/src/language-html/clean.js index ad2769c76..1a3ab5afe 100644 --- a/src/language-html/clean.js +++ b/src/language-html/clean.js @@ -6,6 +6,10 @@ const ignoredProperties = new Set([ "endSourceSpan", "nameSpan", "valueSpan", + "keySpan", + "tagDefinition", + "tokens", + "valueTokens", ]); function clean(ast, newNode) { diff --git a/src/language-html/print-preprocess.js b/src/language-html/print-preprocess.js index 074f73da3..15ba2fe8e 100644 --- a/src/language-html/print-preprocess.js +++ b/src/language-html/print-preprocess.js @@ -338,7 +338,9 @@ function addIsSelfClosing(ast /*, options */) { (node.type === "element" && (node.tagDefinition.isVoid || // self-closing - node.startSourceSpan === node.endSourceSpan)); + (node.endSourceSpan && + node.startSourceSpan.start === node.endSourceSpan.start && + node.startSourceSpan.end === node.endSourceSpan.end))); }); } diff --git a/tests/format/misc/errors/vue/__snapshots__/jsfmt.spec.js.snap b/tests/format/misc/errors/vue/__snapshots__/jsfmt.spec.js.snap index 11aef9f65..13ecf8428 100644 --- a/tests/format/misc/errors/vue/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/errors/vue/__snapshots__/jsfmt.spec.js.snap @@ -1,18 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`unclosed_tag.vue [vue] format 1`] = ` -"Unexpected character "EOF" (2:1) - 1 |
1 |
2 | | ^" `; exports[`unclosed_tag_in_template.vue [vue] format 1`] = ` -"Unexpected character "/" (4:2) +"Unexpected character "<" (4:1) 2 |

Templates are formatted as well... 3 | 4 | - | ^ + | ^ 5 |" `; diff --git a/website/playground/util.js b/website/playground/util.js index 5a20470f7..7e8031cd5 100644 --- a/website/playground/util.js +++ b/website/playground/util.js @@ -56,7 +56,7 @@ const astAutoFold = { estree: /^\s*"(loc|start|end|tokens|leadingComments|trailingComments|innerComments)":/, postcss: /^\s*"(source|input|raws|file)":/, - html: /^\s*"(sourceSpan|valueSpan|nameSpan|startSourceSpan|endSourceSpan|tagDefinition)":/, + html: /^\s*"(\w+Span|valueTokens|tokens|file|tagDefinition)":/, mdast: /^\s*"position":/, yaml: /^\s*"position":/, glimmer: /^\s*"loc":/, diff --git a/yarn.lock b/yarn.lock index 102d67555..a024a4a33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1734,12 +1734,12 @@ __metadata: languageName: node linkType: hard -"angular-html-parser@npm:1.8.0": - version: 1.8.0 - resolution: "angular-html-parser@npm:1.8.0" +"angular-html-parser@npm:2.0.0": + version: 2.0.0 + resolution: "angular-html-parser@npm:2.0.0" dependencies: - tslib: ^1.9.3 - checksum: 3f47a630500f76dcc36aded0d672da3de1de29e262c7bea06041d86653d00e36c1c1f133211095030e730ed9c4f0fe3415db2f2152e7135be963fd39908d69d6 + tslib: 2.4.0 + checksum: 28f815f65959202879c17f8b50287728936b18d8c0b59d48ec7d63943356cf7d9b098b36022f22dfa5baad645922ee86e4d20c7d8b88e9dd18b830f712d9db7b languageName: node linkType: hard @@ -6620,7 +6620,7 @@ __metadata: acorn: 8.8.0 acorn-jsx: 5.3.2 angular-estree-parser: 2.5.1 - angular-html-parser: 1.8.0 + angular-html-parser: 2.0.0 benchmark: 2.1.4 browserslist-to-esbuild: 1.2.0 c8: 7.12.0 @@ -7882,6 +7882,13 @@ __metadata: languageName: node linkType: hard +"tslib@npm:2.4.0, tslib@npm:^2.0.3, tslib@npm:^2.2.0": + version: 2.4.0 + resolution: "tslib@npm:2.4.0" + checksum: 8c4aa6a3c5a754bf76aefc38026134180c053b7bd2f81338cb5e5ebf96fefa0f417bff221592bf801077f5bf990562f6264fecbc42cd3309b33872cb6fc3b113 + languageName: node + linkType: hard + "tslib@npm:^1.10.0, tslib@npm:^1.8.1, tslib@npm:^1.9.0, tslib@npm:^1.9.3": version: 1.14.1 resolution: "tslib@npm:1.14.1" @@ -7889,13 +7896,6 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.0.3, tslib@npm:^2.2.0": - version: 2.4.0 - resolution: "tslib@npm:2.4.0" - checksum: 8c4aa6a3c5a754bf76aefc38026134180c053b7bd2f81338cb5e5ebf96fefa0f417bff221592bf801077f5bf990562f6264fecbc42cd3309b33872cb6fc3b113 - languageName: node - linkType: hard - "tsutils@npm:^3.21.0": version: 3.21.0 resolution: "tsutils@npm:3.21.0"