-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(template-compiler): correctly handle open curly bracket resulting…
… from html character entity (#4312)
- Loading branch information
Showing
11 changed files
with
363 additions
and
8 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...omplex/compatibility/base/html-entities/experimental-complex-expressions-true/actual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<template> | ||
<p>foo&bar</p> | ||
<p>const { foo } = bar;</p> | ||
</template> |
134 changes: 134 additions & 0 deletions
134
...n-complex/compatibility/base/html-entities/experimental-complex-expressions-true/ast.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"root": { | ||
"type": "Root", | ||
"location": { | ||
"startLine": 1, | ||
"startColumn": 1, | ||
"endLine": 4, | ||
"endColumn": 12, | ||
"start": 0, | ||
"end": 87, | ||
"startTag": { | ||
"startLine": 1, | ||
"startColumn": 1, | ||
"endLine": 1, | ||
"endColumn": 11, | ||
"start": 0, | ||
"end": 10 | ||
}, | ||
"endTag": { | ||
"startLine": 4, | ||
"startColumn": 1, | ||
"endLine": 4, | ||
"endColumn": 12, | ||
"start": 76, | ||
"end": 87 | ||
} | ||
}, | ||
"directives": [], | ||
"children": [ | ||
{ | ||
"type": "Element", | ||
"name": "p", | ||
"namespace": "http://www.w3.org/1999/xhtml", | ||
"location": { | ||
"startLine": 2, | ||
"startColumn": 5, | ||
"endLine": 2, | ||
"endColumn": 23, | ||
"start": 15, | ||
"end": 33, | ||
"startTag": { | ||
"startLine": 2, | ||
"startColumn": 5, | ||
"endLine": 2, | ||
"endColumn": 8, | ||
"start": 15, | ||
"end": 18 | ||
}, | ||
"endTag": { | ||
"startLine": 2, | ||
"startColumn": 19, | ||
"endLine": 2, | ||
"endColumn": 23, | ||
"start": 29, | ||
"end": 33 | ||
} | ||
}, | ||
"attributes": [], | ||
"properties": [], | ||
"directives": [], | ||
"listeners": [], | ||
"children": [ | ||
{ | ||
"type": "Text", | ||
"raw": "foo&bar", | ||
"value": { | ||
"type": "Literal", | ||
"value": "foo&bar" | ||
}, | ||
"location": { | ||
"startLine": 2, | ||
"startColumn": 8, | ||
"endLine": 2, | ||
"endColumn": 19, | ||
"start": 18, | ||
"end": 29 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "Element", | ||
"name": "p", | ||
"namespace": "http://www.w3.org/1999/xhtml", | ||
"location": { | ||
"startLine": 3, | ||
"startColumn": 5, | ||
"endLine": 3, | ||
"endColumn": 42, | ||
"start": 38, | ||
"end": 75, | ||
"startTag": { | ||
"startLine": 3, | ||
"startColumn": 5, | ||
"endLine": 3, | ||
"endColumn": 8, | ||
"start": 38, | ||
"end": 41 | ||
}, | ||
"endTag": { | ||
"startLine": 3, | ||
"startColumn": 38, | ||
"endLine": 3, | ||
"endColumn": 42, | ||
"start": 71, | ||
"end": 75 | ||
} | ||
}, | ||
"attributes": [], | ||
"properties": [], | ||
"directives": [], | ||
"listeners": [], | ||
"children": [ | ||
{ | ||
"type": "Text", | ||
"raw": "const { foo } = bar;", | ||
"value": { | ||
"type": "Literal", | ||
"value": "const { foo } = bar;" | ||
}, | ||
"location": { | ||
"startLine": 3, | ||
"startColumn": 8, | ||
"endLine": 3, | ||
"endColumn": 38, | ||
"start": 41, | ||
"end": 71 | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...omplex/compatibility/base/html-entities/experimental-complex-expressions-true/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
25 changes: 25 additions & 0 deletions
25
...omplex/compatibility/base/html-entities/experimental-complex-expressions-true/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import _implicitStylesheets from "./experimental-complex-expressions-true.css"; | ||
import _implicitScopedStylesheets from "./experimental-complex-expressions-true.scoped.css?scoped=true"; | ||
import { freezeTemplate, parseFragment, registerTemplate } from "lwc"; | ||
const $fragment1 = parseFragment`<p${3}>foo&bar</p>`; | ||
const $fragment2 = parseFragment`<p${3}>const { foo } = bar;</p>`; | ||
function tmpl($api, $cmp, $slotset, $ctx) { | ||
const { st: api_static_fragment } = $api; | ||
return [ | ||
api_static_fragment($fragment1, 1), | ||
api_static_fragment($fragment2, 3), | ||
]; | ||
/*LWC compiler vX.X.X*/ | ||
} | ||
export default registerTemplate(tmpl); | ||
tmpl.stylesheets = []; | ||
tmpl.stylesheetToken = "lwc-5t3hn3vkg17"; | ||
tmpl.legacyStylesheetToken = | ||
"x-experimental-complex-expressions-true_experimental-complex-expressions-true"; | ||
if (_implicitStylesheets) { | ||
tmpl.stylesheets.push.apply(tmpl.stylesheets, _implicitStylesheets); | ||
} | ||
if (_implicitScopedStylesheets) { | ||
tmpl.stylesheets.push.apply(tmpl.stylesheets, _implicitScopedStylesheets); | ||
} | ||
freezeTemplate(tmpl); |
3 changes: 3 additions & 0 deletions
3
...plex/compatibility/base/html-entities/experimental-complex-expressions-true/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"warnings": [] | ||
} |
4 changes: 4 additions & 0 deletions
4
...on-complex/compatibility/base/html-entities/static-content-optimization-false/actual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<template> | ||
<p>foo&bar</p> | ||
<p>const { foo } = bar;</p> | ||
</template> |
134 changes: 134 additions & 0 deletions
134
...ssion-complex/compatibility/base/html-entities/static-content-optimization-false/ast.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"root": { | ||
"type": "Root", | ||
"location": { | ||
"startLine": 1, | ||
"startColumn": 1, | ||
"endLine": 4, | ||
"endColumn": 12, | ||
"start": 0, | ||
"end": 87, | ||
"startTag": { | ||
"startLine": 1, | ||
"startColumn": 1, | ||
"endLine": 1, | ||
"endColumn": 11, | ||
"start": 0, | ||
"end": 10 | ||
}, | ||
"endTag": { | ||
"startLine": 4, | ||
"startColumn": 1, | ||
"endLine": 4, | ||
"endColumn": 12, | ||
"start": 76, | ||
"end": 87 | ||
} | ||
}, | ||
"directives": [], | ||
"children": [ | ||
{ | ||
"type": "Element", | ||
"name": "p", | ||
"namespace": "http://www.w3.org/1999/xhtml", | ||
"location": { | ||
"startLine": 2, | ||
"startColumn": 5, | ||
"endLine": 2, | ||
"endColumn": 23, | ||
"start": 15, | ||
"end": 33, | ||
"startTag": { | ||
"startLine": 2, | ||
"startColumn": 5, | ||
"endLine": 2, | ||
"endColumn": 8, | ||
"start": 15, | ||
"end": 18 | ||
}, | ||
"endTag": { | ||
"startLine": 2, | ||
"startColumn": 19, | ||
"endLine": 2, | ||
"endColumn": 23, | ||
"start": 29, | ||
"end": 33 | ||
} | ||
}, | ||
"attributes": [], | ||
"properties": [], | ||
"directives": [], | ||
"listeners": [], | ||
"children": [ | ||
{ | ||
"type": "Text", | ||
"raw": "foo&bar", | ||
"value": { | ||
"type": "Literal", | ||
"value": "foo&bar" | ||
}, | ||
"location": { | ||
"startLine": 2, | ||
"startColumn": 8, | ||
"endLine": 2, | ||
"endColumn": 19, | ||
"start": 18, | ||
"end": 29 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "Element", | ||
"name": "p", | ||
"namespace": "http://www.w3.org/1999/xhtml", | ||
"location": { | ||
"startLine": 3, | ||
"startColumn": 5, | ||
"endLine": 3, | ||
"endColumn": 42, | ||
"start": 38, | ||
"end": 75, | ||
"startTag": { | ||
"startLine": 3, | ||
"startColumn": 5, | ||
"endLine": 3, | ||
"endColumn": 8, | ||
"start": 38, | ||
"end": 41 | ||
}, | ||
"endTag": { | ||
"startLine": 3, | ||
"startColumn": 38, | ||
"endLine": 3, | ||
"endColumn": 42, | ||
"start": 71, | ||
"end": 75 | ||
} | ||
}, | ||
"attributes": [], | ||
"properties": [], | ||
"directives": [], | ||
"listeners": [], | ||
"children": [ | ||
{ | ||
"type": "Text", | ||
"raw": "const { foo } = bar;", | ||
"value": { | ||
"type": "Literal", | ||
"value": "const { foo } = bar;" | ||
}, | ||
"location": { | ||
"startLine": 3, | ||
"startColumn": 8, | ||
"endLine": 3, | ||
"endColumn": 38, | ||
"start": 41, | ||
"end": 71 | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...on-complex/compatibility/base/html-entities/static-content-optimization-false/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"enableStaticContentOptimization": false, | ||
"experimentalComplexExpressions": true | ||
} |
29 changes: 29 additions & 0 deletions
29
...on-complex/compatibility/base/html-entities/static-content-optimization-false/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import _implicitStylesheets from "./static-content-optimization-false.css"; | ||
import _implicitScopedStylesheets from "./static-content-optimization-false.scoped.css?scoped=true"; | ||
import { freezeTemplate, registerTemplate } from "lwc"; | ||
const stc0 = { | ||
key: 0, | ||
}; | ||
const stc1 = { | ||
key: 1, | ||
}; | ||
function tmpl($api, $cmp, $slotset, $ctx) { | ||
const { t: api_text, h: api_element } = $api; | ||
return [ | ||
api_element("p", stc0, [api_text("foo&bar")]), | ||
api_element("p", stc1, [api_text("const { foo } = bar;")]), | ||
]; | ||
/*LWC compiler vX.X.X*/ | ||
} | ||
export default registerTemplate(tmpl); | ||
tmpl.stylesheets = []; | ||
tmpl.stylesheetToken = "lwc-2m6fifibgq7"; | ||
tmpl.legacyStylesheetToken = | ||
"x-static-content-optimization-false_static-content-optimization-false"; | ||
if (_implicitStylesheets) { | ||
tmpl.stylesheets.push.apply(tmpl.stylesheets, _implicitStylesheets); | ||
} | ||
if (_implicitScopedStylesheets) { | ||
tmpl.stylesheets.push.apply(tmpl.stylesheets, _implicitScopedStylesheets); | ||
} | ||
freezeTemplate(tmpl); |
3 changes: 3 additions & 0 deletions
3
...-complex/compatibility/base/html-entities/static-content-optimization-false/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"warnings": [] | ||
} |
Oops, something went wrong.