Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@lwc/errors/src/compiler/error-info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
* Next error code: 1207
* Next error code: 1209
*/

export * from './compiler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,4 +979,20 @@ export const ParserDiagnostics = {
level: DiagnosticLevel.Error,
url: '',
},

COMPUTED_PROPERTY_ACCESS_NOT_ALLOWED_COMPLEX: {
code: 1207,
message:
'Template expression doesn\'t allow computed property access unless the expression is surrounded by quotes: "{0}"',
level: DiagnosticLevel.Error,
url: '',
},

INVALID_NODE_COMPLEX: {
code: 1208,
message:
'Template expression doesn\'t allow {0} unless the expression is surrounded by quotes: "{1}"',
level: DiagnosticLevel.Error,
url: '',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
-->
<template>
<div data-foo={expr1()}></div>
<p class={expr2.expr21.expr22}></p>
<div data-foo="{expr1()}"></div>
<p class="{expr2.expr21.expr22}"></p>
<p>{expr3[0]['expr3' + '3']}</p>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -112,78 +112,66 @@
"raw": "{foo}",
"value": {
"type": "Identifier",
"start": 80,
"end": 83,
"loc": {
"start": {
"line": 4,
"column": 13
},
"end": {
"line": 4,
"column": 16
}
},
"range": [
80,
83
],
"start": 1,
"end": 4,
"name": "foo",
"location": {
"startLine": 4,
"startColumn": 13,
"endLine": 5,
"endColumn": 13,
"start": 79,
"end": 97
"startLine": 3,
"startColumn": 42,
"endLine": 6,
"endColumn": 9,
"start": 66,
"end": 111
}
},
"location": {
"startLine": 4,
"startColumn": 13,
"endLine": 5,
"endColumn": 13,
"start": 79,
"end": 97
"startLine": 3,
"startColumn": 42,
"endLine": 6,
"endColumn": 9,
"start": 66,
"end": 111
}
},
{
"type": "Text",
"raw": " ",
"value": {
"type": "Literal",
"value": " "
},
"location": {
"startLine": 3,
"startColumn": 42,
"endLine": 6,
"endColumn": 9,
"start": 66,
"end": 111
}
},
{
"type": "Text",
"raw": "{bar}",
"value": {
"type": "Identifier",
"start": 98,
"end": 101,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 5,
"column": 16
}
},
"range": [
98,
101
],
"start": 7,
"end": 10,
"name": "bar",
"location": {
"startLine": 5,
"startColumn": 13,
"startLine": 3,
"startColumn": 42,
"endLine": 6,
"endColumn": 9,
"start": 97,
"start": 66,
"end": 111
}
},
"location": {
"startLine": 5,
"startColumn": 13,
"startLine": 3,
"startColumn": 42,
"endLine": 6,
"endColumn": 9,
"start": 97,
"start": 66,
"end": 111
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function tmpl($api, $cmp, $slotset, $ctx) {
return [
api_element("section", stc0, [
$cmp.state.isTrue
? api_text(api_dynamic_text($cmp.foo) + api_dynamic_text($cmp.bar))
? api_text(
api_dynamic_text($cmp.foo) + " " + api_dynamic_text($cmp.bar)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmsjtu - you asked about this in the PR review. I double checked and this expected output now aligns with what the legacy expression parser produces. In other words, it is now correct and it was incorrect before this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanna say hi to the future person coming here because of an investigation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the contrary! The very existence of this change means such an investigation may never occur!

)
: null,
]),
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<button onclick={async () => doSomething()}></button>
<button onclick="{async () => doSomething()}"></button>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"level": 1,
"location": {
"line": 3,
"column": 25,
"start": 50,
"length": 25
"column": 17,
"start": 41,
"length": 37
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<button onblick={() => { doSomething(); }}></button>
<button onblick="{() => { doSomething(); }}"></button>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"level": 1,
"location": {
"line": 3,
"column": 25,
"start": 50,
"length": 24
"column": 17,
"start": 41,
"length": 36
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<button onclick={myField = 'foo'}></button>
<button onclick="{myField = 'foo'}"></button>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"level": 1,
"location": {
"line": 3,
"column": 25,
"start": 50,
"length": 15
"column": 17,
"start": 41,
"length": 27
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<button onclick={await foo()}></button>
<button onclick="{await foo()}"></button>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"level": 1,
"location": {
"line": 3,
"column": 25,
"start": 50,
"length": 11
"column": 17,
"start": 41,
"length": 23
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<x-child foo={transformBigInt(1n)}></x-child>
<x-child foo="{transformBigInt(1n)}"></x-child>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"level": 1,
"location": {
"line": 3,
"column": 22,
"start": 47,
"length": 19
"column": 18,
"start": 42,
"length": 27
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<section>
<x-foo jsclass={
<x-foo jsclass="{
class Bar {
method() {}
}
}></x-foo>
}"></x-foo>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"message": "Invalid expression {\n class Bar {\n method() {}\n }\n } - LWC1196: Use of classes is disallowed within template expressions.",
"level": 1,
"location": {
"line": 4,
"column": 12,
"start": 62,
"length": 53
"line": 3,
"column": 16,
"start": 40,
"length": 87
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<button onclick={(one(), two(), three(), iAmTheCount())}></button>
<button onclick="{one(), two(), three(), iAmTheCount()}"></button>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"warnings": [
{
"code": 1196,
"message": "Invalid expression {(one(), two(), three(), iAmTheCount())} - LWC1196: Use of comma operators is disallowed within template expressions.",
"message": "Invalid expression {one(), two(), three(), iAmTheCount()} - LWC1196: Use of comma operators is disallowed within template expressions.",
"level": 1,
"location": {
"line": 3,
"column": 26,
"start": 51,
"length": 36
"column": 17,
"start": 41,
"length": 48
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<section>
<x-foo field={
<x-foo field="{
/* what do you think ? */
someValue
}></x-foo>
}"></x-foo>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
"warnings": [
{
"code": 1197,
"message": "Unexpected compilation error: LWC1197: Use of comments is disallowed within template expressions.",
"level": 1
"message": "Invalid expression {\n /* what do you think ? */\n someValue\n } - LWC1197: Use of comments is disallowed within template expressions.",
"level": 1,
"location": {
"line": 3,
"column": 16,
"start": 40,
"length": 79
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<button onclick={() => delete baz}></button>
<button onclick="{() => delete baz}"></button>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"level": 1,
"location": {
"line": 3,
"column": 25,
"start": 50,
"length": 16
"column": 17,
"start": 41,
"length": 28
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section>
<x-child onawesomething={function Awesomeness (foo) { bar(foo); }}></x-child>
<x-child onawesomething="{function Awesomeness (foo) { bar(foo); }}"></x-child>
</section>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"level": 1,
"location": {
"line": 3,
"column": 33,
"start": 58,
"length": 40
"column": 18,
"start": 42,
"length": 59
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<!-- This should fail as html characters are not decoded in complex or non-complex expressions -->
<x-foo>{foo &#60; bar}</x-foo>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading