Skip to content

Commit

Permalink
fix(template-compiler): correctly handle open curly bracket resulting…
Browse files Browse the repository at this point in the history
… from html character entity (#4312)
  • Loading branch information
ekashida committed Jun 21, 2024
1 parent 3066552 commit 7b0418c
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<p>foo&amp;bar</p>
<p>const &#123; foo &#125; = bar;</p>
</template>
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&amp;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 &#123; foo &#125; = bar;",
"value": {
"type": "Literal",
"value": "const { foo } = bar;"
},
"location": {
"startLine": 3,
"startColumn": 8,
"endLine": 3,
"endColumn": 38,
"start": 41,
"end": 71
}
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"experimentalComplexExpressions": true
}
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&amp;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);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"warnings": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<p>foo&amp;bar</p>
<p>const &#123; foo &#125; = bar;</p>
</template>
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&amp;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 &#123; foo &#125; = bar;",
"value": {
"type": "Literal",
"value": "const { foo } = bar;"
},
"location": {
"startLine": 3,
"startColumn": 8,
"endLine": 3,
"endColumn": 38,
"start": 41,
"end": 71
}
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"enableStaticContentOptimization": false,
"experimentalComplexExpressions": true
}
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);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"warnings": []
}
Loading

0 comments on commit 7b0418c

Please sign in to comment.