diff --git a/package.json b/package.json index 025040e2b..2c626b02c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@glimmer/syntax": "0.30.3", "@iarna/toml": "2.0.0", "angular-estree-parser": "1.1.5", - "angular-html-parser": "1.1.0", + "angular-html-parser": "1.2.0", "camelcase": "4.1.0", "chalk": "2.1.0", "cjk-regex": "2.0.0", diff --git a/src/language-html/parser-html.js b/src/language-html/parser-html.js index 57c776112..cf1920610 100644 --- a/src/language-html/parser-html.js +++ b/src/language-html/parser-html.js @@ -13,7 +13,8 @@ function ngHtmlParser( recognizeSelfClosing, normalizeTagName, normalizeAttributeName, - allowHtmComponentClosingTags + allowHtmComponentClosingTags, + isTagNameCaseSensitive } ) { const parser = require("angular-html-parser"); @@ -36,7 +37,8 @@ function ngHtmlParser( const { rootNodes, errors } = parser.parse(input, { canSelfClose: recognizeSelfClosing, - allowHtmComponentClosingTags + allowHtmComponentClosingTags, + isTagNameCaseSensitive }); if (errors.length !== 0) { @@ -147,7 +149,9 @@ function ngHtmlParser( const addTagDefinition = node => { if (node instanceof Element) { - const tagDefinition = getHtmlTagDefinition(node.name); + const tagDefinition = getHtmlTagDefinition( + isTagNameCaseSensitive ? node.name : node.name.toLowerCase() + ); if ( !node.namespace || node.namespace === tagDefinition.implicitNamespacePrefix @@ -262,7 +266,8 @@ function createParser({ recognizeSelfClosing = false, normalizeTagName = false, normalizeAttributeName = false, - allowHtmComponentClosingTags = false + allowHtmComponentClosingTags = false, + isTagNameCaseSensitive = false } = {}) { return { parse: (text, parsers, options) => @@ -270,7 +275,8 @@ function createParser({ recognizeSelfClosing, normalizeTagName, normalizeAttributeName, - allowHtmComponentClosingTags + allowHtmComponentClosingTags, + isTagNameCaseSensitive }), hasPragma, astFormat: "html", @@ -288,6 +294,9 @@ module.exports = { allowHtmComponentClosingTags: true }), angular: createParser(), - vue: createParser({ recognizeSelfClosing: true }) + vue: createParser({ + recognizeSelfClosing: true, + isTagNameCaseSensitive: true + }) } }; diff --git a/tests/html_vue/__snapshots__/jsfmt.spec.js.snap b/tests/html_vue/__snapshots__/jsfmt.spec.js.snap index 0362594da..648d73daf 100644 --- a/tests/html_vue/__snapshots__/jsfmt.spec.js.snap +++ b/tests/html_vue/__snapshots__/jsfmt.spec.js.snap @@ -823,6 +823,62 @@ export default { ================================================================================ `; +exports[`case-sensitive-tags.vue 1`] = ` +====================================options===================================== +parsers: ["vue"] +printWidth: 80 + | printWidth +=====================================input====================================== + + +=====================================output===================================== + + +================================================================================ +`; + +exports[`case-sensitive-tags.vue 2`] = ` +====================================options===================================== +parsers: ["vue"] +printWidth: 80 +trailingComma: "es5" + | printWidth +=====================================input====================================== + + +=====================================output===================================== + + +================================================================================ +`; + +exports[`case-sensitive-tags.vue 3`] = ` +====================================options===================================== +parsers: ["vue"] +printWidth: 80 +semi: false + | printWidth +=====================================input====================================== + + +=====================================output===================================== + + +================================================================================ +`; + exports[`custom-block.vue 1`] = ` ====================================options===================================== parsers: ["vue"] diff --git a/tests/html_vue/case-sensitive-tags.vue b/tests/html_vue/case-sensitive-tags.vue new file mode 100644 index 000000000..04a06a6ab --- /dev/null +++ b/tests/html_vue/case-sensitive-tags.vue @@ -0,0 +1,3 @@ + diff --git a/yarn.lock b/yarn.lock index 340c46a88..4eb82ea62 100644 --- a/yarn.lock +++ b/yarn.lock @@ -675,9 +675,9 @@ angular-estree-parser@1.1.5: lines-and-columns "^1.1.6" tslib "^1.9.3" -angular-html-parser@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/angular-html-parser/-/angular-html-parser-1.1.0.tgz#0199c3c675c6bc9e1c7df9b41569c9df99b53f8c" +angular-html-parser@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/angular-html-parser/-/angular-html-parser-1.2.0.tgz#9319b8a9e06389aee2449b3a35977442512eccf3" dependencies: tslib "^1.9.3"