From 31f93c3e07d7dedcff9cce075c2290a41b79dd98 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 29 Feb 2024 09:30:56 -0800 Subject: [PATCH 1/9] refactor: move fragment cache-busting to Karma-only (#4025) Co-authored-by: Will Harney <62956339+wjhsf@users.noreply.github.com> --- .../engine-core/src/framework/template.ts | 30 +++++++++++++++---- .../legacy-scope-tokens/index.spec.js | 3 ++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/@lwc/engine-core/src/framework/template.ts b/packages/@lwc/engine-core/src/framework/template.ts index 6e0bf34b29..2cb85f6815 100644 --- a/packages/@lwc/engine-core/src/framework/template.ts +++ b/packages/@lwc/engine-core/src/framework/template.ts @@ -13,6 +13,8 @@ import { isTrue, isUndefined, KEY__SCOPED_CSS, + keys, + noop, toString, } from '@lwc/shared'; @@ -111,7 +113,26 @@ function validateLightDomTemplate(template: Template, vm: VM) { const enum FragmentCache { HAS_SCOPED_STYLE = 1 << 0, SHADOW_MODE_SYNTHETIC = 1 << 1, - HAS_LEGACY_SCOPE_TOKEN = 1 << 2, +} + +// This should be a no-op outside of LWC's Karma tests, where it's not needed +let registerFragmentCache: (fragmentCache: any) => void = noop; + +// Only used in LWC's Karma tests +if (process.env.NODE_ENV === 'test-karma-lwc') { + // Keep track of fragmentCaches, so we can clear them in LWC's Karma tests + const fragmentCaches: any[] = []; + registerFragmentCache = (fragmentCache: any) => { + fragmentCaches.push(fragmentCache); + }; + + (window as any).__lwcResetFragmentCaches = () => { + for (const fragmentCache of fragmentCaches) { + for (const key of keys(fragmentCache)) { + delete fragmentCache[key]; + } + } + }; } function buildParseFragmentFn( @@ -120,6 +141,8 @@ function buildParseFragmentFn( return (strings: string[], ...keys: number[]) => { const cache = create(null); + registerFragmentCache(cache); + return function (): Element { const { context: { hasScopedStyles, stylesheetToken, legacyStylesheetToken }, @@ -138,11 +161,6 @@ function buildParseFragmentFn( if (hasStyleToken && isSyntheticShadow) { cacheKey |= FragmentCache.SHADOW_MODE_SYNTHETIC; } - if (hasLegacyToken) { - // This isn't strictly required for prod, but it's required for our karma tests - // since the lwcRuntimeFlag may change over time - cacheKey |= FragmentCache.HAS_LEGACY_SCOPE_TOKEN; - } if (!isUndefined(cache[cacheKey])) { return cache[cacheKey]; diff --git a/packages/@lwc/integration-karma/test/rendering/legacy-scope-tokens/index.spec.js b/packages/@lwc/integration-karma/test/rendering/legacy-scope-tokens/index.spec.js index 5b67ac70d3..56478d91de 100644 --- a/packages/@lwc/integration-karma/test/rendering/legacy-scope-tokens/index.spec.js +++ b/packages/@lwc/integration-karma/test/rendering/legacy-scope-tokens/index.spec.js @@ -11,6 +11,9 @@ describe('legacy scope tokens', () => { afterEach(() => { setFeatureFlagForTest('ENABLE_LEGACY_SCOPE_TOKENS', false); + // We keep a cache of parsed static fragments; these need to be reset + // since they can vary based on whether we use the legacy scope token or not. + window.__lwcResetFragmentCaches(); }); function getAttributes(elm) { From fe90773a72d28038677516bc855c0ea149f56b0d Mon Sep 17 00:00:00 2001 From: Eugene Kashida Date: Thu, 29 Feb 2024 12:11:16 -0800 Subject: [PATCH 2/9] fix(template-compiler): avoid mutating the ast when binding complex template expressions (#4026) --- .../valid/array-expr/ast.json | 58 +- .../valid/arrowfn-scoped-vars/ast.json | 51 +- .../valid/assignment-inside-arrow/ast.json | 17 +- .../valid/binary-expr-arithmetic/ast.json | 480 +++++-------- .../valid/binary-expr-bit-shift/ast.json | 102 +-- .../valid/binary-expr-bitwise/ast.json | 348 ++++------ .../valid/binary-expr-logical/ast.json | 232 +++---- .../valid/binary-expr-relational/ast.json | 232 +++---- .../valid/call-expr/ast.json | 58 +- .../valid/iterator/actual.html | 9 + .../valid/iterator/ast.json | 243 +++++++ .../valid/iterator/config.json | 3 + .../valid/iterator/expected.js | 33 + .../valid/iterator/metadata.json | 3 + .../valid/member-expr/ast.json | 116 ++-- .../valid/object-expr/ast.json | 85 ++- .../valid/optional-call-expr/ast.json | 75 +- .../valid/template-literal-tagged/ast.json | 116 ++-- .../valid/template-literal/ast.json | 116 ++-- .../expression-complex/valid/ternary/ast.json | 638 ++++++------------ .../valid/typeof-operator/ast.json | 17 +- .../valid/unary-expr-bitwise/ast.json | 58 +- .../valid/unary-expr-logical/ast.json | 17 +- .../valid/update-inside-arrow/ast.json | 17 +- .../valid/void-operator/ast.json | 17 +- .../template-compiler/src/codegen/codegen.ts | 3 + 26 files changed, 1305 insertions(+), 1839 deletions(-) create mode 100644 packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/actual.html create mode 100644 packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/ast.json create mode 100644 packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/config.json create mode 100644 packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/expected.js create mode 100644 packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/metadata.json diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/array-expr/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/array-expr/ast.json index a62da45f4a..1077cc1416 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/array-expr/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/array-expr/ast.json @@ -107,19 +107,10 @@ "raw": "1" }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 5, - "end": 8, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 5, + "end": 8, + "name": "bar" }, { "type": "Literal", @@ -232,33 +223,24 @@ "raw": "'flop'" }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 91, - "end": 95, - "loc": { - "start": { - "line": 4, - "column": 18 - }, - "end": { - "line": 4, - "column": 22 - } + "type": "Identifier", + "start": 91, + "end": 95, + "loc": { + "start": { + "line": 4, + "column": 18 }, - "range": [ - 91, - 95 - ], - "name": "floo" + "end": { + "line": 4, + "column": 22 + } }, - "computed": false, - "optional": false + "range": [ + 91, + 95 + ], + "name": "floo" }, { "type": "Literal", diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/arrowfn-scoped-vars/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/arrowfn-scoped-vars/ast.json index 3595e966a9..2d6f2180bb 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/arrowfn-scoped-vars/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/arrowfn-scoped-vars/ast.json @@ -67,19 +67,10 @@ "end": 125, "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 15, - "end": 18, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 15, + "end": 18, + "name": "foo" }, { "type": "ArrowFunctionExpression", @@ -105,19 +96,10 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 58, - "end": 61, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 58, + "end": 61, + "name": "foo" }, { "type": "ArrayExpression", @@ -184,19 +166,10 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 111, - "end": 114, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 111, + "end": 114, + "name": "foo" } ] } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/assignment-inside-arrow/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/assignment-inside-arrow/ast.json index 7b1a77ea3c..98640a30a1 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/assignment-inside-arrow/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/assignment-inside-arrow/ast.json @@ -110,19 +110,10 @@ "end": 22, "operator": "=", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "myField" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 14, + "name": "myField" }, "right": { "type": "Literal", diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-arithmetic/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-arithmetic/ast.json index f111418fa8..481bf10998 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-arithmetic/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-arithmetic/ast.json @@ -99,35 +99,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "+", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 3, @@ -173,63 +155,45 @@ 68 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 59, - "end": 62, - "loc": { - "start": { - "line": 3, - "column": 34 - }, - "end": { - "line": 3, - "column": 37 - } + "type": "Identifier", + "start": 59, + "end": 62, + "loc": { + "start": { + "line": 3, + "column": 34 }, - "range": [ - 59, - 62 - ], - "name": "foo" - }, - "computed": false, - "optional": false + "end": { + "line": 3, + "column": 37 + } + }, + "range": [ + 59, + 62 + ], + "name": "foo" }, "operator": "+", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 65, - "end": 68, - "loc": { - "start": { - "line": 3, - "column": 40 - }, - "end": { - "line": 3, - "column": 43 - } + "type": "Identifier", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 40 }, - "range": [ - 65, - 68 - ], - "name": "bar" - }, - "computed": false, - "optional": false + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 65, + 68 + ], + "name": "bar" }, "location": { "startLine": 3, @@ -290,35 +254,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "/", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 4, @@ -364,63 +310,45 @@ 122 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 113, - "end": 116, - "loc": { - "start": { - "line": 4, - "column": 34 - }, - "end": { - "line": 4, - "column": 37 - } + "type": "Identifier", + "start": 113, + "end": 116, + "loc": { + "start": { + "line": 4, + "column": 34 }, - "range": [ - 113, - 116 - ], - "name": "foo" - }, - "computed": false, - "optional": false + "end": { + "line": 4, + "column": 37 + } + }, + "range": [ + 113, + 116 + ], + "name": "foo" }, "operator": "/", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 119, - "end": 122, - "loc": { - "start": { - "line": 4, - "column": 40 - }, - "end": { - "line": 4, - "column": 43 - } + "type": "Identifier", + "start": 119, + "end": 122, + "loc": { + "start": { + "line": 4, + "column": 40 }, - "range": [ - 119, - 122 - ], - "name": "bar" - }, - "computed": false, - "optional": false + "end": { + "line": 4, + "column": 43 + } + }, + "range": [ + 119, + 122 + ], + "name": "bar" }, "location": { "startLine": 4, @@ -481,35 +409,17 @@ "start": 1, "end": 11, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "**", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 8, - "end": 11, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 8, + "end": 11, + "name": "bar" }, "location": { "startLine": 5, @@ -555,63 +465,45 @@ 178 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 168, - "end": 171, - "loc": { - "start": { - "line": 5, - "column": 35 - }, - "end": { - "line": 5, - "column": 38 - } + "type": "Identifier", + "start": 168, + "end": 171, + "loc": { + "start": { + "line": 5, + "column": 35 }, - "range": [ - 168, - 171 - ], - "name": "foo" - }, - "computed": false, - "optional": false + "end": { + "line": 5, + "column": 38 + } + }, + "range": [ + 168, + 171 + ], + "name": "foo" }, "operator": "**", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 175, - "end": 178, - "loc": { - "start": { - "line": 5, - "column": 42 - }, - "end": { - "line": 5, - "column": 45 - } + "type": "Identifier", + "start": 175, + "end": 178, + "loc": { + "start": { + "line": 5, + "column": 42 }, - "range": [ - 175, - 178 - ], - "name": "bar" - }, - "computed": false, - "optional": false + "end": { + "line": 5, + "column": 45 + } + }, + "range": [ + 175, + 178 + ], + "name": "bar" }, "location": { "startLine": 5, @@ -672,35 +564,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "-", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 6, @@ -746,63 +620,45 @@ 232 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 223, - "end": 226, - "loc": { - "start": { - "line": 6, - "column": 34 - }, - "end": { - "line": 6, - "column": 37 - } + "type": "Identifier", + "start": 223, + "end": 226, + "loc": { + "start": { + "line": 6, + "column": 34 }, - "range": [ - 223, - 226 - ], - "name": "foo" - }, - "computed": false, - "optional": false + "end": { + "line": 6, + "column": 37 + } + }, + "range": [ + 223, + 226 + ], + "name": "foo" }, "operator": "-", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 229, - "end": 232, - "loc": { - "start": { - "line": 6, - "column": 40 - }, - "end": { - "line": 6, - "column": 43 - } + "type": "Identifier", + "start": 229, + "end": 232, + "loc": { + "start": { + "line": 6, + "column": 40 }, - "range": [ - 229, - 232 - ], - "name": "bar" - }, - "computed": false, - "optional": false + "end": { + "line": 6, + "column": 43 + } + }, + "range": [ + 229, + 232 + ], + "name": "bar" }, "location": { "startLine": 6, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bit-shift/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bit-shift/ast.json index 7261852467..b9656bd8a8 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bit-shift/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bit-shift/ast.json @@ -99,35 +99,17 @@ "start": 1, "end": 11, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": ">>", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 8, - "end": 11, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 8, + "end": 11, + "name": "bar" }, "location": { "startLine": 3, @@ -191,35 +173,17 @@ "start": 1, "end": 11, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "<<", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 8, - "end": 11, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 8, + "end": 11, + "name": "bar" }, "location": { "startLine": 4, @@ -283,35 +247,17 @@ "start": 1, "end": 12, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": ">>>", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 9, - "end": 12, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 9, + "end": 12, + "name": "bar" }, "location": { "startLine": 5, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bitwise/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bitwise/ast.json index a436a65bd6..fcb1bd4e1c 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bitwise/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-bitwise/ast.json @@ -99,35 +99,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "&", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 3, @@ -173,63 +155,45 @@ 69 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 60, - "end": 63, - "loc": { - "start": { - "line": 3, - "column": 35 - }, - "end": { - "line": 3, - "column": 38 - } + "type": "Identifier", + "start": 60, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 35 }, - "range": [ - 60, - 63 - ], - "name": "foo" + "end": { + "line": 3, + "column": 38 + } }, - "computed": false, - "optional": false + "range": [ + 60, + 63 + ], + "name": "foo" }, "operator": "&", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 66, - "end": 69, - "loc": { - "start": { - "line": 3, - "column": 41 - }, - "end": { - "line": 3, - "column": 44 - } + "type": "Identifier", + "start": 66, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 41 }, - "range": [ - 66, - 69 - ], - "name": "bar" + "end": { + "line": 3, + "column": 44 + } }, - "computed": false, - "optional": false + "range": [ + 66, + 69 + ], + "name": "bar" }, "location": { "startLine": 3, @@ -290,35 +254,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "|", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 4, @@ -364,63 +310,45 @@ 125 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 116, - "end": 119, - "loc": { - "start": { - "line": 4, - "column": 35 - }, - "end": { - "line": 4, - "column": 38 - } + "type": "Identifier", + "start": 116, + "end": 119, + "loc": { + "start": { + "line": 4, + "column": 35 }, - "range": [ - 116, - 119 - ], - "name": "foo" + "end": { + "line": 4, + "column": 38 + } }, - "computed": false, - "optional": false + "range": [ + 116, + 119 + ], + "name": "foo" }, "operator": "|", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 122, - "end": 125, - "loc": { - "start": { - "line": 4, - "column": 41 - }, - "end": { - "line": 4, - "column": 44 - } + "type": "Identifier", + "start": 122, + "end": 125, + "loc": { + "start": { + "line": 4, + "column": 41 }, - "range": [ - 122, - 125 - ], - "name": "bar" + "end": { + "line": 4, + "column": 44 + } }, - "computed": false, - "optional": false + "range": [ + 122, + 125 + ], + "name": "bar" }, "location": { "startLine": 4, @@ -481,35 +409,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "^", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 5, @@ -555,63 +465,45 @@ 181 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 172, - "end": 175, - "loc": { - "start": { - "line": 5, - "column": 35 - }, - "end": { - "line": 5, - "column": 38 - } + "type": "Identifier", + "start": 172, + "end": 175, + "loc": { + "start": { + "line": 5, + "column": 35 }, - "range": [ - 172, - 175 - ], - "name": "foo" + "end": { + "line": 5, + "column": 38 + } }, - "computed": false, - "optional": false + "range": [ + 172, + 175 + ], + "name": "foo" }, "operator": "^", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 178, - "end": 181, - "loc": { - "start": { - "line": 5, - "column": 41 - }, - "end": { - "line": 5, - "column": 44 - } + "type": "Identifier", + "start": 178, + "end": 181, + "loc": { + "start": { + "line": 5, + "column": 41 }, - "range": [ - 178, - 181 - ], - "name": "bar" + "end": { + "line": 5, + "column": 44 + } }, - "computed": false, - "optional": false + "range": [ + 178, + 181 + ], + "name": "bar" }, "location": { "startLine": 5, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-logical/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-logical/ast.json index d66d66df85..b86f36d766 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-logical/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-logical/ast.json @@ -99,35 +99,17 @@ "start": 1, "end": 11, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "||", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 8, - "end": 11, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 8, + "end": 11, + "name": "bar" }, "location": { "startLine": 3, @@ -173,63 +155,45 @@ 70 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 60, - "end": 63, - "loc": { - "start": { - "line": 3, - "column": 35 - }, - "end": { - "line": 3, - "column": 38 - } + "type": "Identifier", + "start": 60, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 35 }, - "range": [ - 60, - 63 - ], - "name": "foo" + "end": { + "line": 3, + "column": 38 + } }, - "computed": false, - "optional": false + "range": [ + 60, + 63 + ], + "name": "foo" }, "operator": "||", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 67, - "end": 70, - "loc": { - "start": { - "line": 3, - "column": 42 - }, - "end": { - "line": 3, - "column": 45 - } + "type": "Identifier", + "start": 67, + "end": 70, + "loc": { + "start": { + "line": 3, + "column": 42 }, - "range": [ - 67, - 70 - ], - "name": "bar" + "end": { + "line": 3, + "column": 45 + } }, - "computed": false, - "optional": false + "range": [ + 67, + 70 + ], + "name": "bar" }, "location": { "startLine": 3, @@ -290,35 +254,17 @@ "start": 1, "end": 11, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "&&", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 8, - "end": 11, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 8, + "end": 11, + "name": "bar" }, "location": { "startLine": 4, @@ -364,63 +310,45 @@ 126 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 116, - "end": 119, - "loc": { - "start": { - "line": 4, - "column": 35 - }, - "end": { - "line": 4, - "column": 38 - } + "type": "Identifier", + "start": 116, + "end": 119, + "loc": { + "start": { + "line": 4, + "column": 35 }, - "range": [ - 116, - 119 - ], - "name": "foo" + "end": { + "line": 4, + "column": 38 + } }, - "computed": false, - "optional": false + "range": [ + 116, + 119 + ], + "name": "foo" }, "operator": "&&", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 123, - "end": 126, - "loc": { - "start": { - "line": 4, - "column": 42 - }, - "end": { - "line": 4, - "column": 45 - } + "type": "Identifier", + "start": 123, + "end": 126, + "loc": { + "start": { + "line": 4, + "column": 42 }, - "range": [ - 123, - 126 - ], - "name": "bar" + "end": { + "line": 4, + "column": 45 + } }, - "computed": false, - "optional": false + "range": [ + 123, + 126 + ], + "name": "bar" }, "location": { "startLine": 4, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-relational/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-relational/ast.json index 21fd828cac..0b63da31df 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-relational/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/binary-expr-relational/ast.json @@ -99,35 +99,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": ">", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 3, @@ -173,63 +155,45 @@ 68 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 59, - "end": 62, - "loc": { - "start": { - "line": 3, - "column": 34 - }, - "end": { - "line": 3, - "column": 37 - } + "type": "Identifier", + "start": 59, + "end": 62, + "loc": { + "start": { + "line": 3, + "column": 34 }, - "range": [ - 59, - 62 - ], - "name": "foo" + "end": { + "line": 3, + "column": 37 + } }, - "computed": false, - "optional": false + "range": [ + 59, + 62 + ], + "name": "foo" }, "operator": ">", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 65, - "end": 68, - "loc": { - "start": { - "line": 3, - "column": 40 - }, - "end": { - "line": 3, - "column": 43 - } + "type": "Identifier", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 40 }, - "range": [ - 65, - 68 - ], - "name": "bar" + "end": { + "line": 3, + "column": 43 + } }, - "computed": false, - "optional": false + "range": [ + 65, + 68 + ], + "name": "bar" }, "location": { "startLine": 3, @@ -290,35 +254,17 @@ "start": 1, "end": 10, "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "operator": "<", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "location": { "startLine": 4, @@ -364,63 +310,45 @@ 122 ], "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 113, - "end": 116, - "loc": { - "start": { - "line": 4, - "column": 34 - }, - "end": { - "line": 4, - "column": 37 - } + "type": "Identifier", + "start": 113, + "end": 116, + "loc": { + "start": { + "line": 4, + "column": 34 }, - "range": [ - 113, - 116 - ], - "name": "foo" + "end": { + "line": 4, + "column": 37 + } }, - "computed": false, - "optional": false + "range": [ + 113, + 116 + ], + "name": "foo" }, "operator": "<", "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 119, - "end": 122, - "loc": { - "start": { - "line": 4, - "column": 40 - }, - "end": { - "line": 4, - "column": 43 - } + "type": "Identifier", + "start": 119, + "end": 122, + "loc": { + "start": { + "line": 4, + "column": 40 }, - "range": [ - 119, - 122 - ], - "name": "bar" + "end": { + "line": 4, + "column": 43 + } }, - "computed": false, - "optional": false + "range": [ + 119, + 122 + ], + "name": "bar" }, "location": { "startLine": 4, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/call-expr/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/call-expr/ast.json index 3901c8c826..61be6f3ead 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/call-expr/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/call-expr/ast.json @@ -99,19 +99,10 @@ "start": 1, "end": 9, "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 7, - "name": "getFoo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 7, + "name": "getFoo" }, "arguments": [], "optional": false, @@ -159,33 +150,24 @@ 66 ], "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 58, - "end": 64, - "loc": { - "start": { - "line": 3, - "column": 33 - }, - "end": { - "line": 3, - "column": 39 - } + "type": "Identifier", + "start": 58, + "end": 64, + "loc": { + "start": { + "line": 3, + "column": 33 }, - "range": [ - 58, - 64 - ], - "name": "getBaz" + "end": { + "line": 3, + "column": 39 + } }, - "computed": false, - "optional": false + "range": [ + 58, + 64 + ], + "name": "getBaz" }, "arguments": [], "optional": false, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/actual.html b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/actual.html new file mode 100644 index 0000000000..e3570452ee --- /dev/null +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/actual.html @@ -0,0 +1,9 @@ + diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/ast.json new file mode 100644 index 0000000000..1fd3635679 --- /dev/null +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/ast.json @@ -0,0 +1,243 @@ +{ + "root": { + "type": "Root", + "location": { + "startLine": 1, + "startColumn": 1, + "endLine": 9, + "endColumn": 12, + "start": 0, + "end": 211, + "startTag": { + "startLine": 1, + "startColumn": 1, + "endLine": 1, + "endColumn": 11, + "start": 0, + "end": 10 + }, + "endTag": { + "startLine": 9, + "startColumn": 1, + "endLine": 9, + "endColumn": 12, + "start": 200, + "end": 211 + } + }, + "directives": [], + "children": [ + { + "type": "ForEach", + "expression": { + "type": "Identifier", + "start": 1, + "end": 6, + "name": "bento", + "location": { + "startLine": 2, + "startColumn": 15, + "endLine": 2, + "endColumn": 31, + "start": 25, + "end": 41 + } + }, + "item": { + "type": "Identifier", + "name": "okazu", + "location": { + "startLine": 2, + "startColumn": 32, + "endLine": 2, + "endColumn": 48, + "start": 42, + "end": 58 + } + }, + "location": { + "startLine": 2, + "startColumn": 5, + "endLine": 8, + "endColumn": 16, + "start": 15, + "end": 199 + }, + "directiveLocation": { + "startLine": 2, + "startColumn": 15, + "endLine": 2, + "endColumn": 31, + "start": 25, + "end": 41 + }, + "children": [ + { + "type": "Element", + "name": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "location": { + "startLine": 3, + "startColumn": 9, + "endLine": 7, + "endColumn": 15, + "start": 68, + "end": 183, + "startTag": { + "startLine": 3, + "startColumn": 9, + "endLine": 3, + "endColumn": 26, + "start": 68, + "end": 85 + }, + "endTag": { + "startLine": 7, + "startColumn": 9, + "endLine": 7, + "endColumn": 15, + "start": 177, + "end": 183 + } + }, + "attributes": [], + "properties": [], + "directives": [ + { + "type": "Directive", + "name": "Key", + "value": { + "type": "Identifier", + "start": 1, + "end": 6, + "name": "okazu", + "location": { + "startLine": 3, + "startColumn": 14, + "endLine": 3, + "endColumn": 25, + "start": 73, + "end": 84 + } + }, + "location": { + "startLine": 3, + "startColumn": 14, + "endLine": 3, + "endColumn": 25, + "start": 73, + "end": 84 + } + } + ], + "listeners": [], + "children": [ + { + "type": "Element", + "name": "a", + "namespace": "http://www.w3.org/1999/xhtml", + "location": { + "startLine": 4, + "startColumn": 13, + "endLine": 6, + "endColumn": 17, + "start": 98, + "end": 168, + "startTag": { + "startLine": 4, + "startColumn": 13, + "endLine": 4, + "endColumn": 46, + "start": 98, + "end": 131 + }, + "endTag": { + "startLine": 6, + "startColumn": 13, + "endLine": 6, + "endColumn": 17, + "start": 164, + "end": 168 + } + }, + "attributes": [], + "properties": [], + "directives": [], + "listeners": [ + { + "type": "EventListener", + "name": "click", + "handler": { + "type": "ArrowFunctionExpression", + "start": 1, + "end": 20, + "id": null, + "expression": true, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "CallExpression", + "start": 7, + "end": 20, + "callee": { + "type": "Identifier", + "start": 7, + "end": 13, + "name": "taberu" + }, + "arguments": [ + { + "type": "Identifier", + "start": 14, + "end": 19, + "name": "okazu" + } + ], + "optional": false + }, + "location": { + "startLine": 4, + "startColumn": 16, + "endLine": 4, + "endColumn": 45, + "start": 101, + "end": 130 + } + }, + "location": { + "startLine": 4, + "startColumn": 16, + "endLine": 4, + "endColumn": 45, + "start": 101, + "end": 130 + } + } + ], + "children": [ + { + "type": "Text", + "raw": "one", + "value": { + "type": "Literal", + "value": "one" + }, + "location": { + "startLine": 4, + "startColumn": 46, + "endLine": 6, + "endColumn": 13, + "start": 131, + "end": 164 + } + } + ] + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/config.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/config.json new file mode 100644 index 0000000000..77a9e76511 --- /dev/null +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/config.json @@ -0,0 +1,3 @@ +{ + "experimentalComplexExpressions": true +} diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/expected.js new file mode 100644 index 0000000000..c7ccd8390c --- /dev/null +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/expected.js @@ -0,0 +1,33 @@ +import { parseFragment, registerTemplate } from "lwc"; +const $fragment1 = parseFragment`one`; +function tmpl($api, $cmp, $slotset, $ctx) { + const { + k: api_key, + b: api_bind, + sp: api_static_part, + st: api_static_fragment, + h: api_element, + i: api_iterator, + } = $api; + const { _m0, _m1 } = $ctx; + return api_iterator($cmp.bento, function (okazu) { + return api_element( + "div", + { + key: api_key(0, okazu), + }, + [ + api_static_fragment($fragment1(), 2, [ + api_static_part(0, { + on: { + click: _m1 || ($ctx._m1 = api_bind(() => $cmp.taberu(okazu))), + }, + }), + ]), + ] + ); + }); + /*LWC compiler vX.X.X*/ +} +export default registerTemplate(tmpl); +tmpl.stylesheets = []; diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/metadata.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/metadata.json new file mode 100644 index 0000000000..51ec5f799c --- /dev/null +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/iterator/metadata.json @@ -0,0 +1,3 @@ +{ + "warnings": [] +} \ No newline at end of file diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/member-expr/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/member-expr/ast.json index e1763573a3..3981cd75f1 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/member-expr/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/member-expr/ast.json @@ -99,19 +99,10 @@ "start": 1, "end": 8, "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "property": { "type": "Identifier", @@ -183,33 +174,24 @@ 64 ], "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 57, - "end": 60, - "loc": { - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 35 - } + "type": "Identifier", + "start": 57, + "end": 60, + "loc": { + "start": { + "line": 3, + "column": 32 }, - "range": [ - 57, - 60 - ], - "name": "foo" + "end": { + "line": 3, + "column": 35 + } }, - "computed": false, - "optional": false + "range": [ + 57, + 60 + ], + "name": "foo" }, "property": { "type": "Identifier", @@ -315,19 +297,10 @@ "start": 1, "end": 10, "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 2, - "end": 5, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 2, + "end": 5, + "name": "foo" }, "property": { "type": "Identifier", @@ -381,33 +354,24 @@ 122 ], "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 114, - "end": 117, - "loc": { - "start": { - "line": 4, - "column": 35 - }, - "end": { - "line": 4, - "column": 38 - } + "type": "Identifier", + "start": 114, + "end": 117, + "loc": { + "start": { + "line": 4, + "column": 35 }, - "range": [ - 114, - 117 - ], - "name": "biz" + "end": { + "line": 4, + "column": 38 + } }, - "computed": false, - "optional": false + "range": [ + 114, + 117 + ], + "name": "biz" }, "property": { "type": "Identifier", diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/object-expr/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/object-expr/ast.json index 3d24d99bc0..21d8288402 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/object-expr/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/object-expr/ast.json @@ -184,8 +184,89 @@ 98 ], "object": { - "type": "Identifier", - "name": "stc2" + "type": "ObjectExpression", + "start": 71, + "end": 88, + "loc": { + "start": { + "line": 3, + "column": 46 + }, + "end": { + "line": 3, + "column": 63 + } + }, + "range": [ + 71, + 88 + ], + "properties": [ + { + "type": "Property", + "start": 73, + "end": 87, + "loc": { + "start": { + "line": 3, + "column": 48 + }, + "end": { + "line": 3, + "column": 62 + } + }, + "range": [ + 73, + 87 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 73, + "end": 76, + "loc": { + "start": { + "line": 3, + "column": 48 + }, + "end": { + "line": 3, + "column": 51 + } + }, + "range": [ + 73, + 76 + ], + "name": "obj" + }, + "value": { + "type": "Literal", + "start": 78, + "end": 87, + "loc": { + "start": { + "line": 3, + "column": 53 + }, + "end": { + "line": 3, + "column": 62 + } + }, + "range": [ + 78, + 87 + ], + "value": "literal", + "raw": "'literal'" + }, + "kind": "init" + } + ] }, "property": { "type": "Identifier", diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/optional-call-expr/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/optional-call-expr/ast.json index a9c8c8189b..75d6965173 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/optional-call-expr/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/optional-call-expr/ast.json @@ -103,35 +103,17 @@ "start": 1, "end": 11, "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "arguments": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" } ], "optional": true @@ -216,33 +198,24 @@ 69 ], "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 60, - "end": 63, - "loc": { - "start": { - "line": 3, - "column": 35 - }, - "end": { - "line": 3, - "column": 38 - } + "type": "Identifier", + "start": 60, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 35 }, - "range": [ - 60, - 63 - ], - "name": "baz" + "end": { + "line": 3, + "column": 38 + } }, - "computed": false, - "optional": false + "range": [ + 60, + 63 + ], + "name": "baz" }, "property": { "type": "Identifier", diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal-tagged/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal-tagged/ast.json index a6902b9ae0..435a96d3a6 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal-tagged/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal-tagged/ast.json @@ -99,19 +99,10 @@ "start": 1, "end": 25, "tag": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "quasi": { "type": "TemplateLiteral", @@ -119,19 +110,10 @@ "end": 25, "expressions": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 18, - "end": 23, - "name": "bizzy" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 18, + "end": 23, + "name": "bizzy" } ], "quasis": [ @@ -201,33 +183,24 @@ 98 ], "tag": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 74, - "end": 77, - "loc": { - "start": { - "line": 3, - "column": 49 - }, - "end": { - "line": 3, - "column": 52 - } + "type": "Identifier", + "start": 74, + "end": 77, + "loc": { + "start": { + "line": 3, + "column": 49 }, - "range": [ - 74, - 77 - ], - "name": "foo" + "end": { + "line": 3, + "column": 52 + } }, - "computed": false, - "optional": false + "range": [ + 74, + 77 + ], + "name": "foo" }, "quasi": { "type": "TemplateLiteral", @@ -249,33 +222,24 @@ ], "expressions": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 91, - "end": 96, - "loc": { - "start": { - "line": 3, - "column": 66 - }, - "end": { - "line": 3, - "column": 71 - } + "type": "Identifier", + "start": 91, + "end": 96, + "loc": { + "start": { + "line": 3, + "column": 66 }, - "range": [ - 91, - 96 - ], - "name": "bizzy" + "end": { + "line": 3, + "column": 71 + } }, - "computed": false, - "optional": false + "range": [ + 91, + 96 + ], + "name": "bizzy" } ], "quasis": [ diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal/ast.json index f9eb4064dd..c26c157db5 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/template-literal/ast.json @@ -100,34 +100,16 @@ "end": 25, "expressions": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 4, - "end": 8, - "name": "name" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 4, + "end": 8, + "name": "name" }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 13, - "end": 23, - "name": "occupation" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 13, + "end": 23, + "name": "occupation" } ], "quasis": [ @@ -207,62 +189,44 @@ ], "expressions": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 77, - "end": 81, - "loc": { - "start": { - "line": 3, - "column": 52 - }, - "end": { - "line": 3, - "column": 56 - } + "type": "Identifier", + "start": 77, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 52 }, - "range": [ - 77, - 81 - ], - "name": "name" + "end": { + "line": 3, + "column": 56 + } }, - "computed": false, - "optional": false + "range": [ + 77, + 81 + ], + "name": "name" }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 86, - "end": 96, - "loc": { - "start": { - "line": 3, - "column": 61 - }, - "end": { - "line": 3, - "column": 71 - } + "type": "Identifier", + "start": 86, + "end": 96, + "loc": { + "start": { + "line": 3, + "column": 61 }, - "range": [ - 86, - 96 - ], - "name": "occupation" + "end": { + "line": 3, + "column": 71 + } }, - "computed": false, - "optional": false + "range": [ + 86, + 96 + ], + "name": "occupation" } ], "quasis": [ diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/ternary/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/ternary/ast.json index bfffaa32d6..1be6734105 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/ternary/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/ternary/ast.json @@ -99,49 +99,22 @@ "start": 1, "end": 16, "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "bar" }, "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 13, - "end": 16, - "name": "baz" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 13, + "end": 16, + "name": "baz" }, "location": { "startLine": 3, @@ -187,91 +160,64 @@ 80 ], "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 65, - "end": 68, - "loc": { - "start": { - "line": 3, - "column": 40 - }, - "end": { - "line": 3, - "column": 43 - } + "type": "Identifier", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 40 }, - "range": [ - 65, - 68 - ], - "name": "foo" + "end": { + "line": 3, + "column": 43 + } }, - "computed": false, - "optional": false + "range": [ + 65, + 68 + ], + "name": "foo" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 71, - "end": 74, - "loc": { - "start": { - "line": 3, - "column": 46 - }, - "end": { - "line": 3, - "column": 49 - } + "type": "Identifier", + "start": 71, + "end": 74, + "loc": { + "start": { + "line": 3, + "column": 46 }, - "range": [ - 71, - 74 - ], - "name": "bar" + "end": { + "line": 3, + "column": 49 + } }, - "computed": false, - "optional": false + "range": [ + 71, + 74 + ], + "name": "bar" }, "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 77, - "end": 80, - "loc": { - "start": { - "line": 3, - "column": 52 - }, - "end": { - "line": 3, - "column": 55 - } + "type": "Identifier", + "start": 77, + "end": 80, + "loc": { + "start": { + "line": 3, + "column": 52 }, - "range": [ - 77, - 80 - ], - "name": "baz" + "end": { + "line": 3, + "column": 55 + } }, - "computed": false, - "optional": false + "range": [ + 77, + 80 + ], + "name": "baz" }, "location": { "startLine": 3, @@ -332,49 +278,22 @@ "start": 1, "end": 12, "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 1, - "end": 4, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 1, + "end": 4, + "name": "foo" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 5, - "end": 8, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 5, + "end": 8, + "name": "bar" }, "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 9, - "end": 12, - "name": "baz" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 9, + "end": 12, + "name": "baz" }, "location": { "startLine": 4, @@ -420,91 +339,64 @@ 138 ], "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 127, - "end": 130, - "loc": { - "start": { - "line": 4, - "column": 36 - }, - "end": { - "line": 4, - "column": 39 - } + "type": "Identifier", + "start": 127, + "end": 130, + "loc": { + "start": { + "line": 4, + "column": 36 }, - "range": [ - 127, - 130 - ], - "name": "foo" + "end": { + "line": 4, + "column": 39 + } }, - "computed": false, - "optional": false + "range": [ + 127, + 130 + ], + "name": "foo" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 131, - "end": 134, - "loc": { - "start": { - "line": 4, - "column": 40 - }, - "end": { - "line": 4, - "column": 43 - } + "type": "Identifier", + "start": 131, + "end": 134, + "loc": { + "start": { + "line": 4, + "column": 40 }, - "range": [ - 131, - 134 - ], - "name": "bar" + "end": { + "line": 4, + "column": 43 + } }, - "computed": false, - "optional": false + "range": [ + 131, + 134 + ], + "name": "bar" }, "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 135, - "end": 138, - "loc": { - "start": { - "line": 4, - "column": 44 - }, - "end": { - "line": 4, - "column": 47 - } + "type": "Identifier", + "start": 135, + "end": 138, + "loc": { + "start": { + "line": 4, + "column": 44 }, - "range": [ - 135, - 138 - ], - "name": "baz" + "end": { + "line": 4, + "column": 47 + } }, - "computed": false, - "optional": false + "range": [ + 135, + 138 + ], + "name": "baz" }, "location": { "startLine": 4, @@ -565,83 +457,38 @@ "start": 2, "end": 30, "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 2, - "end": 5, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 2, + "end": 5, + "name": "foo" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 8, - "end": 11, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 8, + "end": 11, + "name": "bar" }, "alternate": { "type": "ConditionalExpression", "start": 14, "end": 30, "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 14, - "end": 17, - "name": "baz" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 14, + "end": 17, + "name": "baz" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 20, - "end": 23, - "name": "biz" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 20, + "end": 23, + "name": "biz" }, "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 26, - "end": 30, - "name": "buzz" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 26, + "end": 30, + "name": "buzz" } }, "location": { @@ -688,62 +535,44 @@ 233 ], "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 205, - "end": 208, - "loc": { - "start": { - "line": 5, - "column": 56 - }, - "end": { - "line": 5, - "column": 59 - } + "type": "Identifier", + "start": 205, + "end": 208, + "loc": { + "start": { + "line": 5, + "column": 56 }, - "range": [ - 205, - 208 - ], - "name": "foo" + "end": { + "line": 5, + "column": 59 + } }, - "computed": false, - "optional": false + "range": [ + 205, + 208 + ], + "name": "foo" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 211, - "end": 214, - "loc": { - "start": { - "line": 5, - "column": 62 - }, - "end": { - "line": 5, - "column": 65 - } + "type": "Identifier", + "start": 211, + "end": 214, + "loc": { + "start": { + "line": 5, + "column": 62 }, - "range": [ - 211, - 214 - ], - "name": "bar" + "end": { + "line": 5, + "column": 65 + } }, - "computed": false, - "optional": false + "range": [ + 211, + 214 + ], + "name": "bar" }, "alternate": { "type": "ConditionalExpression", @@ -764,91 +593,64 @@ 233 ], "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 217, - "end": 220, - "loc": { - "start": { - "line": 5, - "column": 68 - }, - "end": { - "line": 5, - "column": 71 - } + "type": "Identifier", + "start": 217, + "end": 220, + "loc": { + "start": { + "line": 5, + "column": 68 }, - "range": [ - 217, - 220 - ], - "name": "baz" + "end": { + "line": 5, + "column": 71 + } }, - "computed": false, - "optional": false + "range": [ + 217, + 220 + ], + "name": "baz" }, "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 223, - "end": 226, - "loc": { - "start": { - "line": 5, - "column": 74 - }, - "end": { - "line": 5, - "column": 77 - } + "type": "Identifier", + "start": 223, + "end": 226, + "loc": { + "start": { + "line": 5, + "column": 74 }, - "range": [ - 223, - 226 - ], - "name": "biz" + "end": { + "line": 5, + "column": 77 + } }, - "computed": false, - "optional": false + "range": [ + 223, + 226 + ], + "name": "biz" }, "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 229, - "end": 233, - "loc": { - "start": { - "line": 5, - "column": 80 - }, - "end": { - "line": 5, - "column": 84 - } + "type": "Identifier", + "start": 229, + "end": 233, + "loc": { + "start": { + "line": 5, + "column": 80 }, - "range": [ - 229, - 233 - ], - "name": "buzz" + "end": { + "line": 5, + "column": 84 + } }, - "computed": false, - "optional": false + "range": [ + 229, + 233 + ], + "name": "buzz" } }, "location": { diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/typeof-operator/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/typeof-operator/ast.json index c6735b25e4..97fc3cec5e 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/typeof-operator/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/typeof-operator/ast.json @@ -101,19 +101,10 @@ "operator": "typeof", "prefix": true, "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 8, - "end": 11, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 8, + "end": 11, + "name": "foo" }, "location": { "startLine": 3, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-bitwise/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-bitwise/ast.json index efa94fe3f2..8c59fef184 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-bitwise/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-bitwise/ast.json @@ -101,19 +101,10 @@ "operator": "~", "prefix": true, "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 2, - "end": 5, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 2, + "end": 5, + "name": "foo" }, "location": { "startLine": 3, @@ -161,33 +152,24 @@ "operator": "~", "prefix": true, "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 55, - "end": 58, - "loc": { - "start": { - "line": 3, - "column": 30 - }, - "end": { - "line": 3, - "column": 33 - } + "type": "Identifier", + "start": 55, + "end": 58, + "loc": { + "start": { + "line": 3, + "column": 30 }, - "range": [ - 55, - 58 - ], - "name": "bar" + "end": { + "line": 3, + "column": 33 + } }, - "computed": false, - "optional": false + "range": [ + 55, + 58 + ], + "name": "bar" }, "location": { "startLine": 3, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-logical/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-logical/ast.json index 50af8fd043..d2b5c81ca4 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-logical/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/unary-expr-logical/ast.json @@ -101,19 +101,10 @@ "operator": "!", "prefix": true, "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 2, - "end": 5, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 2, + "end": 5, + "name": "foo" }, "location": { "startLine": 3, diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/update-inside-arrow/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/update-inside-arrow/ast.json index cc4b849a09..c4203fa83d 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/update-inside-arrow/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/update-inside-arrow/ast.json @@ -111,19 +111,10 @@ "operator": "++", "prefix": false, "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 7, - "end": 10, - "name": "foo" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 7, + "end": 10, + "name": "foo" } }, "location": { diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/void-operator/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/void-operator/ast.json index 5522b05d3f..367956f536 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/void-operator/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/void-operator/ast.json @@ -101,19 +101,10 @@ "operator": "void", "prefix": true, "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "$cmp" - }, - "property": { - "type": "Identifier", - "start": 6, - "end": 9, - "name": "bar" - }, - "computed": false, - "optional": false + "type": "Identifier", + "start": 6, + "end": 9, + "name": "bar" }, "location": { "startLine": 3, diff --git a/packages/@lwc/template-compiler/src/codegen/codegen.ts b/packages/@lwc/template-compiler/src/codegen/codegen.ts index 479bd89d5c..ce452894f9 100644 --- a/packages/@lwc/template-compiler/src/codegen/codegen.ts +++ b/packages/@lwc/template-compiler/src/codegen/codegen.ts @@ -498,6 +498,9 @@ export default class CodeGen { // TODO [#3370]: remove experimental template expression flag if (this.state.config.experimentalComplexExpressions) { + // Cloning here is necessary because `this.replace()` is destructive, and we might use the + // node later during static content optimization + expression = doStructuredClone(expression); return bindComplexExpression(expression as ComplexExpression, this); } From 57272efb361d842cdcdf419d80db371b4ebc4705 Mon Sep 17 00:00:00 2001 From: Will Harney <62956339+wjhsf@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:41:58 -0500 Subject: [PATCH 3/9] docs: add more JSDoc for top-level exports @W-13278716 (#4028) * docs(features): add more JSDoc for top-level exports * docs(wire-service): add more JSDoc for top-level exports * docs(lwc): fix up JSDoc * docs(compiler): add JSDoc for @lwc/compiler * docs(engine-server): polish JSDoc for @lwc/engine-server * chore: is anyone gonna read this commit message? * docs(engine-dom): polish JSDoc for @lwc/engine-dom * chore: avoid using magic string in comment --- .eslintrc | 9 +-- packages/@lwc/compiler/src/index.ts | 5 +- packages/@lwc/compiler/src/options.ts | 44 ++++++++++++-- .../compiler/src/transformers/javascript.ts | 11 +++- .../@lwc/compiler/src/transformers/style.ts | 11 +++- .../compiler/src/transformers/template.ts | 11 ++-- .../compiler/src/transformers/transformer.ts | 57 +++++++++++++++---- .../apis/build-custom-element-constructor.ts | 12 +++- .../engine-dom/src/apis/create-element.ts | 18 +++--- .../engine-dom/src/apis/hydrate-component.ts | 12 ++++ .../src/apis/is-node-from-template.ts | 4 +- .../@lwc/engine-dom/src/renderer-factory.ts | 7 ++- .../@lwc/engine-dom/src/renderer/context.ts | 5 ++ .../engine-server/src/apis/create-element.ts | 5 +- .../src/apis/render-component.ts | 14 ++++- packages/@lwc/engine-server/src/serializer.ts | 7 ++- .../@lwc/engine-server/src/utils/classes.ts | 14 ++++- .../src/utils/validate-style-text-contents.ts | 23 +++++--- packages/@lwc/features/src/index.ts | 3 + packages/@lwc/features/src/types.ts | 5 ++ packages/@lwc/wire-service/src/index.ts | 4 ++ .../wire-service/src/value-changed-event.ts | 3 +- .../lwc/__tests__/default-exports.spec.ts | 3 +- packages/lwc/index.d.ts | 6 ++ 24 files changed, 232 insertions(+), 61 deletions(-) diff --git a/.eslintrc b/.eslintrc index 2ab6ca44a0..5fba76d9ab 100644 --- a/.eslintrc +++ b/.eslintrc @@ -306,20 +306,19 @@ }, { "files": [ - "packages/lwc/**", // Private packages - documentation isn't required (but should still be good, if present) "packages/@lwc/integration-karma/**", "packages/@lwc/integration-tests/**", "packages/@lwc/perf-benchmarks-components/**", "packages/@lwc/perf-benchmarks/**", // TODO [W-13278716]: All top-level exports should have JSDOC enforced - "packages/@lwc/compiler/**", "packages/@lwc/engine-core/**", - "packages/@lwc/engine-dom/**", - "packages/@lwc/engine-server/**", + // "packages/@lwc/engine-server/**", // Package-level exports are documented, but not all file-level exports are, so we // should keep these disabled for now "packages/@lwc/babel-plugin-component/**", + "packages/@lwc/engine-dom/**", + "packages/@lwc/engine-server/**", "packages/@lwc/module-resolver/**", "packages/@lwc/shared/**", "packages/@lwc/style-compiler/**", @@ -341,7 +340,9 @@ { "files": [ "packages/@lwc/babel-plugin-component/**", + "packages/@lwc/compiler/**", "packages/@lwc/errors/**", + "packages/@lwc/engine-dom/**", "packages/@lwc/rollup-plugin/**", "packages/@lwc/wire-service/**" ], diff --git a/packages/@lwc/compiler/src/index.ts b/packages/@lwc/compiler/src/index.ts index f3fa3608f0..c5715cfac1 100755 --- a/packages/@lwc/compiler/src/index.ts +++ b/packages/@lwc/compiler/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -15,4 +15,5 @@ export { OutputConfig, } from './options'; -export const version = process.env.LWC_VERSION as string; +/** The version of LWC being used. */ +export const version = process.env.LWC_VERSION!; diff --git a/packages/@lwc/compiler/src/options.ts b/packages/@lwc/compiler/src/options.ts index edcd781b6d..f24d758b9a 100755 --- a/packages/@lwc/compiler/src/options.ts +++ b/packages/@lwc/compiler/src/options.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -52,7 +52,7 @@ const DEFAULT_OUTPUT_CONFIG: Required = { export type CustomPropertiesResolution = { type: 'native' } | { type: 'module'; name: string }; /** - * @deprecated - Custom property transforms are deprecated because IE11 and other legacy browsers are no longer supported. + * @deprecated Custom property transforms are deprecated because IE11 and other legacy browsers are no longer supported. */ // TODO [#3266]: Remove StylesheetConfig as part of breaking change wishlist export interface StylesheetConfig { @@ -79,29 +79,53 @@ export interface DynamicImportConfig { strictSpecifier?: boolean; } +/** + * Options used to change the behavior of the compiler. At a minimum, `name` and `namespace` are + * required. + */ export interface TransformOptions { + /** The name of the component. For example, the name in `` is `"component"`. */ name?: string; + /** The namespace of the component. For example, the namespace in `` is `"my"`. */ namespace?: string; + /** @deprecated Ignored by compiler. */ stylesheetConfig?: StylesheetConfig; // TODO [#3331]: deprecate / rename this compiler option in 246 - /* Config applied in usage of dynamic import statements in javascript */ + /** Config applied in usage of dynamic import statements in javascript */ experimentalDynamicComponent?: DynamicImportConfig; - /* Flag to enable usage of dynamic component(lwc:dynamic) directive in HTML template */ + /** Flag to enable usage of dynamic component(lwc:dynamic) directive in HTML template */ experimentalDynamicDirective?: boolean; - /* Flag to enable usage of dynamic component(lwc:is) directive in HTML template */ + /** Flag to enable usage of dynamic component(lwc:is) directive in HTML template */ enableDynamicComponents?: boolean; // TODO [#3370]: remove experimental template expression flag + /** Flag to enable use of (a subset of) JavaScript expressions in place of template bindings. Passed to `@lwc/template-compiler`. */ experimentalComplexExpressions?: boolean; + /** Options to control what output gets generated. */ outputConfig?: OutputConfig; + /** Whether this is an explicit import. Passed to `@lwc/babel-plugin-component`. */ isExplicitImport?: boolean; + /** Whether the compiled HTML should include comments present in the source. */ preserveHtmlComments?: boolean; + /** Whether the CSS file being compiled is a scoped stylesheet. Passed to `@lwc/style-compiler`. */ scopedStyles?: boolean; + /** Whether the static content optimization should be enabled. Passed to `@lwc/template-compiler`. */ enableStaticContentOptimization?: boolean; + /** Custom renderer config to pass to `@lwc/template-compiler`. See that package's README for details. */ customRendererConfig?: CustomRendererConfig; + /** @deprecated Ignored by compiler. `lwc:spread` is always enabled. */ enableLwcSpread?: boolean; + /** Set to true if synthetic shadow DOM support is not needed, which can result in smaller output. */ disableSyntheticShadowSupport?: boolean; + /** + * Enable transformations specific to {@link https://developer.salesforce.com/docs/platform/lwc/guide/security-lwsec-intro.html Lighting Web Security}. + */ enableLightningWebSecurityTransforms?: boolean; + /** + * Instrumentation object to gather metrics and non-error logs for internal use. + * See the `@lwc/errors` package for details on the interface. + */ instrumentation?: InstrumentationObject; + /** API version to associate with the compiled module. Values correspond to Salesforce platform releases. */ apiVersion?: number; } @@ -131,6 +155,16 @@ export interface NormalizedTransformOptions extends RecursiveRequired { createVM(elm, Ctor, renderer, { diff --git a/packages/@lwc/engine-dom/src/apis/hydrate-component.ts b/packages/@lwc/engine-dom/src/apis/hydrate-component.ts index a17cb210ea..84bad8a940 100644 --- a/packages/@lwc/engine-dom/src/apis/hydrate-component.ts +++ b/packages/@lwc/engine-dom/src/apis/hydrate-component.ts @@ -46,6 +46,18 @@ function createVMWithProps(element: Element, Ctor: typeof LightningElement, prop return vm; } +/** + * Replaces an existing DOM node with an LWC component. + * @param element The existing node in the DOM that where the root component should be attached. + * @param Ctor The LWC class to use as the root component. + * @param props Any props for the root component as part of initial client-side rendering. The props must be identical to those passed to renderComponent during SSR. + * @throws Throws when called with invalid parameters. + * @example + * import { hydrateComponent } from 'lwc'; + * import App from 'x/App'; + * const elm = document.querySelector('x-app'); + * hydrateComponent(elm, App, { name: 'Hello World' }); + */ export function hydrateComponent( element: Element, Ctor: typeof LightningElement, diff --git a/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts b/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts index 5af864e3e9..fdeb85ebd9 100644 --- a/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts +++ b/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts @@ -21,7 +21,9 @@ const _Node = Node; /** * EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED * ONCE LOCKER V1 IS NO LONGER SUPPORTED. - * @param node + * @param node Node to check + * @returns `true` if the the node is shadowed + * @example isNodeShadowed(document.querySelector('my-component')) */ function isNodeShadowed(node: Node): boolean { if (isFalse(node instanceof _Node)) { diff --git a/packages/@lwc/engine-dom/src/renderer-factory.ts b/packages/@lwc/engine-dom/src/renderer-factory.ts index 27a6fb5a6a..b61605454d 100644 --- a/packages/@lwc/engine-dom/src/renderer-factory.ts +++ b/packages/@lwc/engine-dom/src/renderer-factory.ts @@ -31,12 +31,15 @@ export type RendererAPIType = Type extends RendererAPI ? RendererAPI : San * A factory function that produces a renderer. * Renderer encapsulates operations that are required to render an LWC component into the underlying * runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment. - * Example usage: + * @param baseRenderer Either null or the base renderer imported from 'lwc'. + * @returns The created renderer + * @example * import { renderer, rendererFactory } from 'lwc'; * const customRenderer = rendererFactory(renderer); - * @param baseRenderer Either null or the base renderer imported from 'lwc'. */ export function rendererFactory(baseRenderer: T): RendererAPIType { + // Type assertion because this is replaced by rollup with an object, not a string. + // See `injectInlineRenderer` in /scripts/rollup/rollup.config.js const renderer = process.env.RENDERER as unknown as RendererAPIType; // Meant to inherit any properties passed via the base renderer as the argument to the factory. Object.setPrototypeOf(renderer, baseRenderer); diff --git a/packages/@lwc/engine-dom/src/renderer/context.ts b/packages/@lwc/engine-dom/src/renderer/context.ts index 24157ecc10..fc2f7c3d7b 100644 --- a/packages/@lwc/engine-dom/src/renderer/context.ts +++ b/packages/@lwc/engine-dom/src/renderer/context.ts @@ -33,6 +33,11 @@ export class WireContextSubscriptionEvent extends CustomEvent { } } +/** + * Creates a context provider, given a wire adapter constructor. + * @param adapter The wire adapter to create a context provider for. + * @returns A new context provider. + */ export function createContextProvider(adapter: WireAdapterConstructor) { return createContextProviderWithRegister(adapter, registerContextProvider); } diff --git a/packages/@lwc/engine-server/src/apis/create-element.ts b/packages/@lwc/engine-server/src/apis/create-element.ts index 93ed79eea7..739197e765 100644 --- a/packages/@lwc/engine-server/src/apis/create-element.ts +++ b/packages/@lwc/engine-server/src/apis/create-element.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -11,7 +11,8 @@ * * The whole point of defining this and exporting it is so that you can import it in isomorphic code without * an error being thrown by the import itself. + * @throws Always throws, as it should not be used. */ -export function createElement() { +export function createElement(): never { throw new Error('createElement is not supported in @lwc/engine-server, only @lwc/engine-dom.'); } diff --git a/packages/@lwc/engine-server/src/apis/render-component.ts b/packages/@lwc/engine-server/src/apis/render-component.ts index acb9fd7c8e..2d030e7222 100644 --- a/packages/@lwc/engine-server/src/apis/render-component.ts +++ b/packages/@lwc/engine-server/src/apis/render-component.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -32,6 +32,18 @@ const FakeRootElement: HostElement = { [HostContextProvidersKey]: new Map(), }; +/** + * Renders a string representation of a serialized component tree. + * @param tagName The name of the tag to render. + * @param Ctor The LWC constructor to render with. + * @returns A string representation of the serialized component tree. + * @throws Throws when called with invalid parameters. + * @example + * import { renderComponent } from '@lwc/engine-server'; + * import LightningHello from 'lightning/hello'; + * const componentProps = {}; + * const serialized = renderComponent('lightning-hello', LightningHello, componentProps); + */ export function renderComponent( tagName: string, Ctor: typeof LightningElement, diff --git a/packages/@lwc/engine-server/src/serializer.ts b/packages/@lwc/engine-server/src/serializer.ts index 97b24ad77d..f86318f21d 100644 --- a/packages/@lwc/engine-server/src/serializer.ts +++ b/packages/@lwc/engine-server/src/serializer.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -59,6 +59,11 @@ function serializeShadowRoot(shadowRoot: HostShadowRoot): string { )}`; } +/** + * Serializes an element into a string + * @param element The element to serialize + * @returns A string representation of the element + */ export function serializeElement(element: HostElement): string { let output = ''; diff --git a/packages/@lwc/engine-server/src/utils/classes.ts b/packages/@lwc/engine-server/src/utils/classes.ts index e6814a219e..9df71facdd 100644 --- a/packages/@lwc/engine-server/src/utils/classes.ts +++ b/packages/@lwc/engine-server/src/utils/classes.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -7,10 +7,22 @@ const CLASSNAMES_SEPARATOR = /\s+/g; +/** + * Splits the given space-delimited string into unique values. + * @param value The string to split + * @returns Set of unique values + * @example classNametoTokenList('foo bar foo') // Set(2) { 'foo', 'bar' } + */ export function classNameToTokenList(value: string): Set { return new Set(value.split(CLASSNAMES_SEPARATOR).filter((str) => str.length)); } +/** + * Converts a set of values into a space-delimited string + * @param values The set of values to join + * @returns A space-delimited string + * @example tokenListToClassName(new Set(['hello', 'world'])) // 'hello world' + */ export function tokenListToClassName(values: Set): string { return Array.from(values).join(' '); } diff --git a/packages/@lwc/engine-server/src/utils/validate-style-text-contents.ts b/packages/@lwc/engine-server/src/utils/validate-style-text-contents.ts index 13eb97338a..844fe8839a 100644 --- a/packages/@lwc/engine-server/src/utils/validate-style-text-contents.ts +++ b/packages/@lwc/engine-server/src/utils/validate-style-text-contents.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -24,13 +24,20 @@ function isSingleStyleNodeContainingSingleTextNode(node: DocumentFragment) { return textNode.nodeName === '#text'; } -// The text content inside ``, -// since a user could use that inside of a *.css file to break out of a `, + * since a user could use that inside of a *.css file to break out of a ') // Throws + */ export function validateStyleTextContents(contents: string): void { // If parse5 parses this as more than one ``); diff --git a/packages/@lwc/features/src/index.ts b/packages/@lwc/features/src/index.ts index a438b7c255..0503473b31 100644 --- a/packages/@lwc/features/src/index.ts +++ b/packages/@lwc/features/src/index.ts @@ -9,6 +9,7 @@ import { FeatureFlagMap, FeatureFlagName, FeatureFlagValue } from './types'; // When deprecating a feature flag, ensure that it is also no longer set in the application. For // example, in core, the flag should be removed from LwcPermAndPrefUtilImpl.java +/** List of all feature flags available, with the default value `null`. */ const features: FeatureFlagMap = { PLACEHOLDER_TEST_FLAG: null, ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null, @@ -26,6 +27,7 @@ if (!(globalThis as any).lwcRuntimeFlags) { Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) }); } +/** Feature flags that have been set. */ const flags: Partial = (globalThis as any).lwcRuntimeFlags; /** @@ -96,5 +98,6 @@ export { export type { FeatureFlagMap }; declare global { + /** Feature flags that have been set. */ const lwcRuntimeFlags: Partial; } diff --git a/packages/@lwc/features/src/types.ts b/packages/@lwc/features/src/types.ts index aa780681ad..72a44e76f3 100644 --- a/packages/@lwc/features/src/types.ts +++ b/packages/@lwc/features/src/types.ts @@ -15,9 +15,14 @@ */ export type FeatureFlagValue = boolean | null; +/** + * Map of feature flags to whether each feature is enabled. Feature flags can be toggled to change + * the behavior of LWC components. + */ export interface FeatureFlagMap { /** * This is only used to test that feature flags are actually working + * @internal */ PLACEHOLDER_TEST_FLAG: FeatureFlagValue; diff --git a/packages/@lwc/wire-service/src/index.ts b/packages/@lwc/wire-service/src/index.ts index 57d79c810f..0af876ca2d 100644 --- a/packages/@lwc/wire-service/src/index.ts +++ b/packages/@lwc/wire-service/src/index.ts @@ -78,6 +78,10 @@ type ConfigListener = (config: ConfigListenerArgument) => void; type WireEventTargetListener = NoArgumentListener | ConfigListener; +/** + * An implementation of the {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/EventTarget EventTarget} + * interface for the wire adapter. + */ export interface WireEventTarget { addEventListener: (type: string, listener: WireEventTargetListener) => void; removeEventListener: (type: string, listener: WireEventTargetListener) => void; diff --git a/packages/@lwc/wire-service/src/value-changed-event.ts b/packages/@lwc/wire-service/src/value-changed-event.ts index 6c342c8ea6..0484f4ab2a 100644 --- a/packages/@lwc/wire-service/src/value-changed-event.ts +++ b/packages/@lwc/wire-service/src/value-changed-event.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -11,6 +11,7 @@ const ValueChangedEventType = 'ValueChangedEvent'; * Event fired by wire adapters to emit a new value. */ export class ValueChangedEvent { + /** The new value. */ value: any; type: string; constructor(value: any) { diff --git a/packages/lwc/__tests__/default-exports.spec.ts b/packages/lwc/__tests__/default-exports.spec.ts index f96a9c68c7..5ad84ae5cc 100644 --- a/packages/lwc/__tests__/default-exports.spec.ts +++ b/packages/lwc/__tests__/default-exports.spec.ts @@ -19,11 +19,10 @@ const expectExportDefaultFromPackageInFile = (pkgName: string, ext: string) => { expect(contents).toMatch(exportDefaultFromPackage); }; -/** +/* * Jest uses CommonJS, which means that packages with no explicit export statements actually export * the default `module.exports` empty object. That export is an empty object with the prototype set * to an empty object with null prototype. - * @param mod */ const hasExplicitDefaultExport = (mod: object) => { // No default export = self explanatory diff --git a/packages/lwc/index.d.ts b/packages/lwc/index.d.ts index ce09987b2c..b8c5aba22d 100644 --- a/packages/lwc/index.d.ts +++ b/packages/lwc/index.d.ts @@ -209,6 +209,12 @@ declare module 'lwc' { * is the returned value. * @param adapter the adapter used to provision data * @param config configuration object for the adapter + * @returns A decorator function + * @example + * export default class WireExample extends LightningElement { + * \@api bookId; + * \@wire(getBook, { id: '$bookId'}) book; + * } */ export function wire< Config extends StringKeyedRecord, From 4f37435261b95577ee6e143ae15c69739cff37c3 Mon Sep 17 00:00:00 2001 From: Will Harney <62956339+wjhsf@users.noreply.github.com> Date: Sat, 2 Mar 2024 17:03:04 -0500 Subject: [PATCH 4/9] chore: avoid @ts-ignore (#4027) * chore: avoid @ts-ignore * chore: finish incomplete changes * fix(types): replace @ts-expect-error with type assertion * fix: avoid type errors * chore: restore explicit return type to minimize diff * refactor: use HTMLElement shadowRoot instead of defining our own * chore: remove unnecessary assertion * fix(types): correctly indicate undefined can be returned --- .eslintrc | 2 -- .../src/framework/base-bridge-element.ts | 2 +- .../src/framework/base-lightning-element.ts | 15 ++++++++++----- .../src/framework/check-version-mismatch.ts | 3 +-- .../engine-core/src/framework/freeze-template.ts | 2 +- .../engine-core/src/framework/restrictions.ts | 4 ++-- packages/@lwc/engine-core/src/framework/vm.ts | 10 ++-------- .../engine-core/src/framework/wiring/wiring.ts | 4 ++-- .../src/patches/detect-non-standard-aria.ts | 8 ++++---- packages/@lwc/engine-core/src/shared/logger.ts | 5 ++--- packages/@lwc/engine-dom/src/styles.ts | 3 +-- .../@lwc/features/src/__tests__/features.spec.ts | 2 +- .../src/__tests__/lwcRuntimeFlags.spec.ts | 2 +- .../features/src/__tests__/setFeatureFlag.spec.ts | 6 +++--- .../src/__tests__/apiVersion/apiVersion.spec.ts | 5 ++--- .../synthetic-shadow/src/faux-shadow/focus.ts | 4 ++-- .../src/faux-shadow/html-element.ts | 4 ++-- .../src/faux-shadow/shadow-root.ts | 2 +- .../@lwc/synthetic-shadow/src/faux-shadow/slot.ts | 2 +- .../synthetic-shadow/src/faux-shadow/traverse.ts | 2 +- .../src/polyfills/event-target/polyfill.ts | 10 +++++----- .../template-compiler/src/__tests__/index.spec.ts | 2 +- .../src/parser/expression-complex/html.ts | 6 +++--- packages/lwc/index.d.ts | 2 +- 24 files changed, 50 insertions(+), 57 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5fba76d9ab..7269aca064 100644 --- a/.eslintrc +++ b/.eslintrc @@ -146,8 +146,6 @@ /* * TODO: Address violations and re-enable these rules */ - // All @ts-ignore should either be refactored or changed to @ts-expect-error - "@typescript-eslint/ban-ts-comment": "off", // Enums are a pain to deal with... "@typescript-eslint/no-unsafe-enum-comparison": "off", // We might just want to leave this one disabled diff --git a/packages/@lwc/engine-core/src/framework/base-bridge-element.ts b/packages/@lwc/engine-core/src/framework/base-bridge-element.ts index dc63b61694..123ce49f54 100644 --- a/packages/@lwc/engine-core/src/framework/base-bridge-element.ts +++ b/packages/@lwc/engine-core/src/framework/base-bridge-element.ts @@ -98,7 +98,7 @@ function createAttributeChangedCallback( if (!isUndefined(superAttributeChangedCallback)) { // delegate unknown attributes to the super. // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch superAttributeChangedCallback.apply(this, arguments); } return; diff --git a/packages/@lwc/engine-core/src/framework/base-lightning-element.ts b/packages/@lwc/engine-core/src/framework/base-lightning-element.ts index d7e8878ad6..94a8d2802f 100644 --- a/packages/@lwc/engine-core/src/framework/base-lightning-element.ts +++ b/packages/@lwc/engine-core/src/framework/base-lightning-element.ts @@ -179,6 +179,7 @@ type HTMLElementTheGoodParts = { toString: () => string } & Pick< | 'removeEventListener' | 'setAttribute' | 'setAttributeNS' + | 'shadowRoot' | 'spellcheck' | 'tabIndex' | 'tagName' @@ -190,8 +191,9 @@ type RefNodes = { [name: string]: Element }; const refsCache: WeakMap = new WeakMap(); export interface LightningElement extends HTMLElementTheGoodParts, AccessibleElementProperties { + constructor: LightningElementConstructor; template: ShadowRoot | null; - refs: RefNodes; + refs: RefNodes | undefined; render(): Template; connectedCallback?(): void; disconnectedCallback?(): void; @@ -207,7 +209,7 @@ export interface LightningElement extends HTMLElementTheGoodParts, AccessibleEle * This class is the base class for any LWC element. * Some elements directly extends this class, others implement it via inheritance. */ -// @ts-ignore +// @ts-expect-error When exported, it will conform, but we need to build it first! export const LightningElement: LightningElementConstructor = function ( this: LightningElement ): LightningElement { @@ -397,8 +399,8 @@ function createElementInternalsProxy( return elementInternalsProxy; } -// @ts-ignore -LightningElement.prototype = { +// Type assertion because we need to build the prototype before it satisfies the interface. +(LightningElement as { prototype: Partial }).prototype = { constructor: LightningElement, dispatchEvent(event: Event): boolean { @@ -721,7 +723,10 @@ LightningElement.prototype = { if (process.env.NODE_ENV !== 'production') { warnIfInvokedDuringConstruction(vm, 'childNodes'); } - return renderer.getChildNodes(vm.elm); + // getChildNodes returns a NodeList, which has `item(index: number): Node | null`. + // NodeListOf extends NodeList, but claims to not return null. That seems inaccurate, + // but these are built-in types, so ultimately not our problem. + return renderer.getChildNodes(vm.elm) as NodeListOf; }, get firstChild() { diff --git a/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts b/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts index bdfc4c7e0e..6bccd1022b 100644 --- a/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts +++ b/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts @@ -17,8 +17,7 @@ let warned = false; // Only used in LWC's Karma tests if (process.env.NODE_ENV === 'test-karma-lwc') { - // @ts-ignore - window.__lwcResetWarnedOnVersionMismatch = () => { + (window as any).__lwcResetWarnedOnVersionMismatch = () => { warned = false; }; } diff --git a/packages/@lwc/engine-core/src/framework/freeze-template.ts b/packages/@lwc/engine-core/src/framework/freeze-template.ts index 08afccbb28..11ad6e4d11 100644 --- a/packages/@lwc/engine-core/src/framework/freeze-template.ts +++ b/packages/@lwc/engine-core/src/framework/freeze-template.ts @@ -118,7 +118,7 @@ function warnOnArrayMutation(stylesheets: TemplateStylesheetFactories) { const originalArrayMethod = getOriginalArrayMethod(prop); stylesheets[prop] = function arrayMutationWarningWrapper() { reportTemplateViolation('stylesheets'); - // @ts-ignore + // @ts-expect-error can't properly determine the right `this` return originalArrayMethod.apply(this, arguments); }; } diff --git a/packages/@lwc/engine-core/src/framework/restrictions.ts b/packages/@lwc/engine-core/src/framework/restrictions.ts index b50c6ac889..97439ee288 100644 --- a/packages/@lwc/engine-core/src/framework/restrictions.ts +++ b/packages/@lwc/engine-core/src/framework/restrictions.ts @@ -195,7 +195,7 @@ function getShadowRootRestrictionsDescriptors(sr: ShadowRoot): PropertyDescripto ); } // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return originalAddEventListener.apply(this, arguments); }, }), @@ -256,7 +256,7 @@ function getCustomElementRestrictionsDescriptors(elm: HTMLElement): PropertyDesc ); } // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return originalAddEventListener.apply(this, arguments); }, }), diff --git a/packages/@lwc/engine-core/src/framework/vm.ts b/packages/@lwc/engine-core/src/framework/vm.ts index 82c91f6c18..a918038dbd 100644 --- a/packages/@lwc/engine-core/src/framework/vm.ts +++ b/packages/@lwc/engine-core/src/framework/vm.ts @@ -303,11 +303,7 @@ function resetComponentStateWhenRemoved(vm: VM) { // old vnode.children is removed from the DOM. export function removeVM(vm: VM) { if (process.env.NODE_ENV !== 'production') { - if ( - !shouldUseNativeCustomElementLifecycle( - vm.component.constructor as LightningElementConstructor - ) - ) { + if (!shouldUseNativeCustomElementLifecycle(vm.component.constructor)) { // With native lifecycle, we cannot be certain that connectedCallback was called before a component // was removed from the VDOM. If the component is disconnected, then connectedCallback will not fire // in native mode, although it will fire in synthetic mode due to appendChild triggering it. @@ -718,9 +714,7 @@ export function runConnectedCallback(vm: VM) { // we're in dev mode. This is to detect a particular issue with synthetic lifecycle. if ( process.env.IS_BROWSER && - !shouldUseNativeCustomElementLifecycle( - vm.component.constructor as LightningElementConstructor - ) && + !shouldUseNativeCustomElementLifecycle(vm.component.constructor) && (process.env.NODE_ENV !== 'production' || isReportingEnabled()) ) { if (!vm.renderer.isConnected(vm.elm)) { diff --git a/packages/@lwc/engine-core/src/framework/wiring/wiring.ts b/packages/@lwc/engine-core/src/framework/wiring/wiring.ts index 31e5af1506..8dd8c491ce 100644 --- a/packages/@lwc/engine-core/src/framework/wiring/wiring.ts +++ b/packages/@lwc/engine-core/src/framework/wiring/wiring.ts @@ -77,7 +77,7 @@ function createConfigWatcher( ro.observe(() => (config = configCallback(component))); // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo // TODO: dev-mode validation of config based on the adapter.configSchema - // @ts-ignore it is assigned in the observe() callback + // @ts-expect-error it is assigned in the observe() callback callbackWhenConfigIsReady(config); }; return { @@ -191,7 +191,7 @@ function createConnector( }); } return { - // @ts-ignore the boundary protection executes sync, connector is always defined + // @ts-expect-error the boundary protection executes sync, connector is always defined connector, computeConfigAndUpdate, resetConfigWatcher: () => ro.reset(), diff --git a/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts b/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts index 38567d6d23..739d6f2481 100644 --- a/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts +++ b/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts @@ -100,19 +100,19 @@ function enableDetection() { throw new Error('detect-non-standard-aria.ts loaded before @lwc/aria-reflection'); } } - // @ts-ignore - const { get, set } = descriptor; + + const { get, set } = descriptor!; // It's important for this defineProperty call to happen _after_ ARIA accessors are applied to the // BaseBridgeElement and LightningElement prototypes. Otherwise, we will log/report for access of non-standard // props on these prototypes, which we actually don't want. We only care about access on generic HTMLElements. defineProperty(prototype, prop, { get() { checkAndReportViolation(this, prop, false, undefined); - return get.call(this); + return get!.call(this); }, set(val) { checkAndReportViolation(this, prop, true, val); - return set.call(this, val); + return set!.call(this, val); }, configurable: true, enumerable: true, diff --git a/packages/@lwc/engine-core/src/shared/logger.ts b/packages/@lwc/engine-core/src/shared/logger.ts index 7ced48e31a..e06725c63c 100644 --- a/packages/@lwc/engine-core/src/shared/logger.ts +++ b/packages/@lwc/engine-core/src/shared/logger.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, salesforce.com, inc. + * Copyright (c) 2024, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT @@ -13,8 +13,7 @@ const alreadyLoggedMessages = new Set(); // Only used in LWC's Karma tests if (process.env.NODE_ENV === 'test-karma-lwc') { - // @ts-ignore - window.__lwcResetAlreadyLoggedMessages = () => { + (window as any).__lwcResetAlreadyLoggedMessages = () => { alreadyLoggedMessages.clear(); }; } diff --git a/packages/@lwc/engine-dom/src/styles.ts b/packages/@lwc/engine-dom/src/styles.ts index dc1feecd6e..899ffb7a73 100644 --- a/packages/@lwc/engine-dom/src/styles.ts +++ b/packages/@lwc/engine-dom/src/styles.ts @@ -52,8 +52,7 @@ const stylesheetCache: Map = new Map(); // Only used in LWC's Karma tests if (process.env.NODE_ENV === 'test-karma-lwc') { - // @ts-ignore - window.__lwcResetGlobalStylesheets = () => { + (window as any).__lwcResetGlobalStylesheets = () => { stylesheetCache.clear(); }; } diff --git a/packages/@lwc/features/src/__tests__/features.spec.ts b/packages/@lwc/features/src/__tests__/features.spec.ts index bf19a3bb42..b9c0451ab9 100644 --- a/packages/@lwc/features/src/__tests__/features.spec.ts +++ b/packages/@lwc/features/src/__tests__/features.spec.ts @@ -16,7 +16,7 @@ describe('features', () => { }); it('unknown flags in the features map are undefined', () => { - // @ts-ignore + // @ts-expect-error explicitly testing JS behavior that violates TS types expect(features.DOES_NOT_EXIST).toBeUndefined(); }); }); diff --git a/packages/@lwc/features/src/__tests__/lwcRuntimeFlags.spec.ts b/packages/@lwc/features/src/__tests__/lwcRuntimeFlags.spec.ts index ac6ebe0e68..e281a415cb 100644 --- a/packages/@lwc/features/src/__tests__/lwcRuntimeFlags.spec.ts +++ b/packages/@lwc/features/src/__tests__/lwcRuntimeFlags.spec.ts @@ -13,7 +13,7 @@ describe('lwcRuntimeFlags', () => { }); it('unknown flags default to undefined', () => { - // @ts-ignore + // @ts-expect-error Explicitly testing JS behavior that violates TS types expect(lwcRuntimeFlags.DOES_NOT_EXIST).toBeUndefined(); }); }); diff --git a/packages/@lwc/features/src/__tests__/setFeatureFlag.spec.ts b/packages/@lwc/features/src/__tests__/setFeatureFlag.spec.ts index 16c18d84a4..7fdfa94cea 100644 --- a/packages/@lwc/features/src/__tests__/setFeatureFlag.spec.ts +++ b/packages/@lwc/features/src/__tests__/setFeatureFlag.spec.ts @@ -32,7 +32,7 @@ describe('setFeatureFlag', () => { const expectedError = 'Failed to set the value "foo" for the runtime feature flag "PLACEHOLDER_TEST_FLAG". Runtime feature flags can only be set to a boolean value.'; const callback = () => { - // @ts-ignore + // @ts-expect-error Explicitly testing JS behavior that violates TS types setFeatureFlag('PLACEHOLDER_TEST_FLAG', 'foo'); }; if (env === 'production') { @@ -47,14 +47,14 @@ describe('setFeatureFlag', () => { }); it('logs and does nothing when the flag is unknown', () => { - // @ts-ignore + // @ts-expect-error Explicitly testing JS behavior that violates TS types setFeatureFlag('DOES_NOT_EXIST', true); expect(info).toHaveBeenCalledWith( expect.stringMatching(/Attempt to set a value on an unknown feature flag/) ); // value is not changed - // @ts-ignore + // @ts-expect-error Explicitly testing JS behavior that violates TS types expect(lwcRuntimeFlags.DOES_NOT_EXIST).toBeUndefined(); }); diff --git a/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts b/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts index ad5f7bc44a..36bebfc1cc 100644 --- a/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts +++ b/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts @@ -50,7 +50,7 @@ describe('API versioning', () => { it('handles apiVersion lower than lower bound', async () => { const { code, warnings } = await runRollup('fixtures/basic/basic.js', { - // @ts-ignore + // @ts-expect-error Explicitly testing JS behavior that violates TS types apiVersion: 0, }); expect(code).toContain(`apiVersion: ${LOWEST_API_VERSION}`); @@ -59,7 +59,6 @@ describe('API versioning', () => { it('handles apiVersion higher than high bound', async () => { const { code, warnings } = await runRollup('fixtures/basic/basic.js', { - // @ts-ignore apiVersion: Number.MAX_SAFE_INTEGER, }); expect(code).toContain(`apiVersion: ${HIGHEST_API_VERSION}`); @@ -68,7 +67,7 @@ describe('API versioning', () => { it('if within bounds, finds the lowest known version matching the specification', async () => { const { code, warnings } = await runRollup('fixtures/basic/basic.js', { - // @ts-ignore` + // @ts-expect-error Explicitly testing JS behavior that violates TS types apiVersion: 58.5, }); expect(code).toContain(`apiVersion: 58`); diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts index 29f36b9497..f440853525 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts @@ -118,7 +118,7 @@ export function hostElementFocus(this: HTMLElement) { // observable differences for component authors between synthetic and native. const focusable = querySelector.call(this, FocusableSelector) as HTMLElement; if (!isNull(focusable)) { - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch focusable.focus.apply(focusable, arguments); } return; @@ -139,7 +139,7 @@ export function hostElementFocus(this: HTMLElement) { let didFocus = false; while (!didFocus && focusables.length !== 0) { const focusable = focusables.shift()!; - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch focusable.focus.apply(focusable, arguments); // Get the root node of the current focusable in case it was slotted. const currentRootNode = focusable.getRootNode() as unknown as DocumentOrShadowRoot; diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts index d90885c35e..40fc80a890 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts @@ -141,7 +141,7 @@ function focusPatched(this: HTMLElement) { } // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch focus.apply(this, arguments); // Restore state by enabling if originally enabled @@ -183,7 +183,7 @@ defineProperties(HTMLElement.prototype, { focus: { value(this: HTMLElement) { // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch focusPatched.apply(this, arguments); }, enumerable: true, diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts index 94bf3125d3..2861346653 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts @@ -353,7 +353,7 @@ const NodePatchDescriptors = { value(this: ShadowRoot, evt: Event): boolean { eventToShadowRootMap.set(evt, this); // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return dispatchEvent.apply(getHost(this), arguments); }, }, diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts index 07954355a4..213a23cfa7 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts @@ -75,7 +75,7 @@ function getFilteredSlotFlattenNodes(slot: HTMLElement): Node[] { const childNodes = arrayFromCollection(childNodesGetter.call(slot)); // Typescript is inferring the wrong function type for this particular // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972 - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return ArrayReduce.call( childNodes, (seed, child) => { diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts index cf7403f8e8..e9ac1f005f 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts @@ -243,7 +243,7 @@ export function getFilteredChildNodes(node: Node): Element[] { const resolver = getShadowRootResolver(getShadowRoot(node)); // Typescript is inferring the wrong function type for this particular // overloaded method: https://github.com/Microsoft/TypeScript/issues/27972 - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return ArrayReduce.call( slots, (seed, slot) => { diff --git a/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts b/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts index 7651f7145e..9480f38775 100644 --- a/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts +++ b/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts @@ -25,7 +25,7 @@ function patchedAddEventListener( ) { if (isSyntheticShadowHost(this)) { // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return addCustomElementEventListener.apply(this, arguments); } if (arguments.length < 2) { @@ -36,7 +36,7 @@ function patchedAddEventListener( args[1] = getEventListenerWrapper(args[1]); } // Ignore types because we're passing through to native method - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return nativeAddEventListener.apply(this, args); } // Fast path. This function is optimized to avoid ArraySlice because addEventListener is called @@ -55,7 +55,7 @@ function patchedRemoveEventListener( ) { if (isSyntheticShadowHost(this)) { // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch return removeCustomElementEventListener.apply(this, arguments); } const args = ArraySlice.call(arguments); @@ -63,11 +63,11 @@ function patchedRemoveEventListener( args[1] = getEventListenerWrapper(args[1]); } // Ignore types because we're passing through to native method - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch nativeRemoveEventListener.apply(this, args); // Account for listeners that were added before this polyfill was applied // Typescript does not like it when you treat the `arguments` object as an array - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch nativeRemoveEventListener.apply(this, arguments); } diff --git a/packages/@lwc/template-compiler/src/__tests__/index.spec.ts b/packages/@lwc/template-compiler/src/__tests__/index.spec.ts index ff41cee654..5254390cd1 100644 --- a/packages/@lwc/template-compiler/src/__tests__/index.spec.ts +++ b/packages/@lwc/template-compiler/src/__tests__/index.spec.ts @@ -10,7 +10,7 @@ import compile, { Config, parse } from '../index'; describe('option validation', () => { it('validated presence of options', () => { expect(() => { - // @ts-ignore + // @ts-expect-error Explicitly testing JS behavior that violates TS types compile(``); }).toThrow(/Compiler options must be an object/); }); diff --git a/packages/@lwc/template-compiler/src/parser/expression-complex/html.ts b/packages/@lwc/template-compiler/src/parser/expression-complex/html.ts index 10886acb27..5ee9a3fe31 100644 --- a/packages/@lwc/template-compiler/src/parser/expression-complex/html.ts +++ b/packages/@lwc/template-compiler/src/parser/expression-complex/html.ts @@ -89,7 +89,7 @@ function validateMatchingExtraParens(leadingChars: string, trailingChars: string * specified by the HTML spec. */ class TemplateHtmlTokenizer extends Tokenizer { - // @ts-ignore + // @ts-expect-error This Preprocessor is an incomplete customization of parse5's Preprocessor preprocessor!: Preprocessor; parser: TemplateHtmlParser; @@ -171,7 +171,7 @@ class TemplateHtmlTokenizer extends Tokenizer { // coming later in an unquoted attr value should not be considered // the beginning of a template expression. this.checkedAttrs.add(this.currentAttr); - // @ts-ignore + // @ts-expect-error private method super._stateAttributeValueUnquoted(codePoint); } } @@ -210,7 +210,7 @@ class TemplateHtmlTokenizer extends Tokenizer { this.currentToken = null; this.currentCharacterToken = null; } else { - // @ts-ignore + // @ts-expect-error private method super._stateData(codePoint); } } diff --git a/packages/lwc/index.d.ts b/packages/lwc/index.d.ts index b8c5aba22d..ba483f32fc 100644 --- a/packages/lwc/index.d.ts +++ b/packages/lwc/index.d.ts @@ -107,7 +107,7 @@ declare module 'lwc' { role: string | null; } - // @ts-ignore type-mismatch + // @ts-expect-error type-mismatch interface ShadowRootTheGoodPart extends NodeSelector { mode: string; readonly activeElement: Element | null; From 36e53a02227ca8f8f15e125067d0db0b07eb1e35 Mon Sep 17 00:00:00 2001 From: Eugene Kashida Date: Sun, 3 Mar 2024 23:54:47 -0800 Subject: [PATCH 5/9] test: enable test for native shadow (#4031) --- .../event-post-dispatch.spec.js | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/packages/@lwc/integration-karma/test/shadow-dom/event-in-shadow-tree/event-post-dispatch.spec.js b/packages/@lwc/integration-karma/test/shadow-dom/event-in-shadow-tree/event-post-dispatch.spec.js index 2db91b45ac..649afaae4d 100644 --- a/packages/@lwc/integration-karma/test/shadow-dom/event-in-shadow-tree/event-post-dispatch.spec.js +++ b/packages/@lwc/integration-karma/test/shadow-dom/event-in-shadow-tree/event-post-dispatch.spec.js @@ -30,18 +30,14 @@ describe('post-dispatch event state', () => { expect(event.target).toBe(nodes['x-container']); }); - // WebKit bug - https://bugs.webkit.org/show_bug.cgi?id=206374 - // In Safari, the event target is not null. - if (!process.env.NATIVE_SHADOW) { - it('{ bubbles: true, composed: false }', () => { - const nodes = createComponent(); - const event = new CustomEvent('test', { bubbles: true, composed: false }); - nodes.container_div.dispatchEvent(event); + it('{ bubbles: true, composed: false }', () => { + const nodes = createComponent(); + const event = new CustomEvent('test', { bubbles: true, composed: false }); + nodes.container_div.dispatchEvent(event); - assertEventStateReset(event); - expect(event.target).toBe(null); - }); - } + assertEventStateReset(event); + expect(event.target).toBe(null); + }); }); describe('lwc:dom="manual" element', () => { @@ -57,21 +53,17 @@ describe('post-dispatch event state', () => { }); }); - // WebKit bug - https://bugs.webkit.org/show_bug.cgi?id=206374 - // In Safari, the event target is not null. - if (!process.env.NATIVE_SHADOW) { - it('{ bubbles: true, composed: false }', () => { - const nodes = createComponent(); - const event = new CustomEvent('test', { bubbles: true, composed: false }); - nodes.container_span_manual.dispatchEvent(event); - - // lwc:dom=manual is async due to MutationObserver - return new Promise(setTimeout).then(() => { - assertEventStateReset(event); - expect(event.target).toBe(null); - }); + it('{ bubbles: true, composed: false }', () => { + const nodes = createComponent(); + const event = new CustomEvent('test', { bubbles: true, composed: false }); + nodes.container_span_manual.dispatchEvent(event); + + // lwc:dom=manual is async due to MutationObserver + return new Promise(setTimeout).then(() => { + assertEventStateReset(event); + expect(event.target).toBe(null); }); - } + }); }); describe('component', () => { From 943fe6e10ed91d8c31cffc9cfee9ca5668c0a299 Mon Sep 17 00:00:00 2001 From: Jason Ye <40873183+jye-sf@users.noreply.github.com> Date: Mon, 4 Mar 2024 08:10:14 -0800 Subject: [PATCH 6/9] fix: event listener not being invoked for native web components (#4012) * fix: event listener not being invoked for native web components * chore: simplify test * chore: test tweaks * chore: also avoid wrapping listeners for non-Node EventTargets * chore: account for light dom nodes * chore: account for window --------- Co-authored-by: Eugene Kashida --- .../composed-path/index.spec.js | 44 +++++++++++++++++++ .../composed-path/x/test/component.js | 18 ++++++++ .../composed-path/x/test/test.html | 3 ++ .../composed-path/x/test/test.js | 30 +++++++++++++ .../src/polyfills/event-target/polyfill.ts | 9 ++++ 5 files changed, 104 insertions(+) create mode 100644 packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/index.spec.js create mode 100644 packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/component.js create mode 100644 packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.html create mode 100644 packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.js diff --git a/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/index.spec.js b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/index.spec.js new file mode 100644 index 0000000000..3f7d0f6eea --- /dev/null +++ b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/index.spec.js @@ -0,0 +1,44 @@ +import { createElement } from 'lwc'; +import Test from 'x/test'; + +describe('event.composedPath() of event dispatched from closed shadow root', () => { + it('should have shadowed elements when invoked inside the shadow root', () => { + const elm = createElement('x-test', { is: Test }); + document.body.appendChild(elm); + + return Promise.resolve().then(() => { + elm.clickShadowedButton(); + + expect(elm.getShadowedComposedPath()).toEqual([ + jasmine.any(HTMLElement), // button + jasmine.any(Object), // #shadow-root(closed) + elm.child, + elm.shadowRoot, + elm, + document.body, + document.documentElement, + document, + window, + ]); + }); + }); + + it('should not have shadowed elements when invoked outside the shadow root', () => { + const elm = createElement('x-test', { is: Test }); + document.body.appendChild(elm); + + return Promise.resolve().then(() => { + elm.clickShadowedButton(); + + expect(elm.getComposedPath()).toEqual([ + elm.child, + elm.shadowRoot, + elm, + document.body, + document.documentElement, + document, + window, + ]); + }); + }); +}); diff --git a/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/component.js b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/component.js new file mode 100644 index 0000000000..bbd072254e --- /dev/null +++ b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/component.js @@ -0,0 +1,18 @@ +customElements.define( + 'x-mixed-shadow-mode-composed-path', + class extends HTMLElement { + constructor() { + super(); + this._shadowRoot = this.attachShadow({ mode: 'closed' }); + this._button = document.createElement('button'); + this._button.addEventListener('click', (event) => { + this.composedPath = event.composedPath(); + }); + this._shadowRoot.appendChild(this._button); + } + + click() { + this._button.click(); + } + } +); diff --git a/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.html b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.html new file mode 100644 index 0000000000..dd2a0f96b0 --- /dev/null +++ b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.js b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.js new file mode 100644 index 0000000000..06e66215ed --- /dev/null +++ b/packages/@lwc/integration-karma/test/mixed-shadow-mode/composed-path/x/test/test.js @@ -0,0 +1,30 @@ +import { LightningElement, api } from 'lwc'; +import './component.js'; + +export default class Parent extends LightningElement { + composedPath; + + @api + get child() { + return this.refs.child; + } + + @api + getShadowedComposedPath() { + return this.child.composedPath; + } + + @api + getComposedPath() { + return this.composedPath; + } + + @api + clickShadowedButton() { + this.child.click(); + } + + handleClick(event) { + this.composedPath = event.composedPath(); + } +} diff --git a/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts b/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts index 9480f38775..1c421c62a4 100644 --- a/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts +++ b/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts @@ -10,6 +10,8 @@ import { eventTargetPrototype, removeEventListener as nativeRemoveEventListener, } from '../../env/event-target'; +import { Node } from '../../env/node'; +import { isInstanceOfNativeShadowRoot } from '../../env/shadow-root'; import { addCustomElementEventListener, removeCustomElementEventListener, @@ -28,6 +30,13 @@ function patchedAddEventListener( // @ts-expect-error type-mismatch return addCustomElementEventListener.apply(this, arguments); } + + if (this instanceof Node && isInstanceOfNativeShadowRoot(this.getRootNode())) { + // Typescript does not like it when you treat the `arguments` object as an array + // @ts-expect-error type-mismatch + return nativeAddEventListener.apply(this, arguments); + } + if (arguments.length < 2) { // Slow path, unlikely to be called frequently. We expect modern browsers to throw: // https://googlechrome.github.io/samples/event-listeners-mandatory-arguments/ From 8c934c512af8698152a2c18e1adbd734fdd1b172 Mon Sep 17 00:00:00 2001 From: Jason Ye <40873183+jye-sf@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:33:11 -0800 Subject: [PATCH 7/9] =?UTF-8?q?feat:=20support=20generating=20inlined=20so?= =?UTF-8?q?urcemaps=20when=20transforming=20js=20file=E2=80=A6=20(#4033)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: support generating inlined sourcemaps when transforming js files in the LWC compiler * feat: support sourcemaps through rollup plugin * fix: additional tests * fix: add test for existing use case --- packages/@lwc/compiler/README.md | 2 +- packages/@lwc/compiler/src/options.ts | 5 +- .../__tests__/transform-javascript.spec.ts | 60 +++++++++++++++++++ .../src/compiler/error-info/compiler.ts | 3 +- packages/@lwc/rollup-plugin/src/index.ts | 4 +- 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/packages/@lwc/compiler/README.md b/packages/@lwc/compiler/README.md index fd1269482c..51299e50cd 100644 --- a/packages/@lwc/compiler/README.md +++ b/packages/@lwc/compiler/README.md @@ -46,7 +46,7 @@ const { code } = transformSync(source, filename, options); - `experimentalDynamicDirective` (type: `boolean`, default: `false`) - The configuration to pass to `@lwc/template-compiler` to enable deprecated dynamic components. - `enableDynamicComponents` (type: `boolean`, default: `false`) - The configuration to pass to `@lwc/template-compiler` to enable dynamic components. - `outputConfig` (type: `object`, optional) - see below: - - `sourcemap` (type: `boolean`, optional) - if `true`, a sourcemap is generated for the transformed file. + - `sourcemap` (type: `boolean` | `'inline'`, optional) - if `true`, a sourcemap is generated for the transformed file. If `'inline'`, an inline sourcemap is generated and appended to the transformed file. - `minify` (type: `boolean`, optional, deprecated) - this option has no effect. - `experimentalComplexExpressions` (type: `boolean`, optional) - set to true to enable use of (a subset of) JavaScript expressions in place of template bindings. Passed to `@lwc/template-compiler`. - `isExplicitImport` (type: `boolean`, optional) - true if this is an explicit import, passed to `@lwc/babel-plugin-component`. diff --git a/packages/@lwc/compiler/src/options.ts b/packages/@lwc/compiler/src/options.ts index f24d758b9a..e0005841ae 100755 --- a/packages/@lwc/compiler/src/options.ts +++ b/packages/@lwc/compiler/src/options.ts @@ -64,9 +64,10 @@ export interface StylesheetConfig { export interface OutputConfig { /** * If `true` a source map is generated for the transformed file. + * If `inline`, an inline source map is generated and appended to the end of the transformed file. * @default false */ - sourcemap?: boolean; + sourcemap?: boolean | 'inline'; /** * @deprecated The minify property has no effect on the generated output. @@ -202,7 +203,7 @@ function isUndefinedOrBoolean(property: any): boolean { function validateOutputConfig(config: OutputConfig) { invariant( - isUndefinedOrBoolean(config.sourcemap), + isUndefinedOrBoolean(config.sourcemap) || config.sourcemap === 'inline', CompilerValidationErrors.INVALID_SOURCEMAP_PROPERTY, [config.sourcemap] ); diff --git a/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts b/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts index ea38b68fb0..a45676e5d1 100644 --- a/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts +++ b/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts @@ -209,3 +209,63 @@ describe('unnecessary registerDecorators', () => { expect(code).toContain('registerDecorators'); }); }); + +describe('sourcemaps', () => { + it("should generate inline sourcemaps when the output config includes the 'inline' option for sourcemaps", () => { + const source = ` + import { LightningElement } from 'lwc'; + export default class Foo extends LightningElement {} + `; + + const { code, map } = transformSync(source, 'foo.js', { + ...TRANSFORMATION_OPTIONS, + outputConfig: { + sourcemap: 'inline', + }, + }); + expect(code).toContain('//# sourceMappingURL=data:application/json;'); + expect(map).toBeNull(); + }); + + it("should generate sourcemaps when the sourcemap configuration value is 'true'", () => { + const source = ` + import { LightningElement } from 'lwc'; + export default class Foo extends LightningElement {} + `; + + const { map } = transformSync(source, 'foo.js', { + ...TRANSFORMATION_OPTIONS, + outputConfig: { + sourcemap: true, + }, + }); + expect(map).not.toBeNull(); + }); + + describe("should fail validation of options if sourcemap configuration value is neither boolean nor 'inline'.", () => { + const source = ` + import { LightningElement } from 'lwc'; + export default class Foo extends LightningElement {} + `; + + [ + { name: 'invalid string', sourcemap: 'invalid' }, + { name: 'object', sourcemap: {} }, + { name: 'numbers', sourcemap: 123 }, + ].forEach(({ name, sourcemap }) => { + it(name, () => { + expect(() => + transformSync(source, 'foo.js', { + ...TRANSFORMATION_OPTIONS, + outputConfig: { + // @ts-expect-error Property can be passed from JS environments with no type checking. + sourcemap, + }, + }) + ).toThrow( + `LWC1021: Expected a boolean value or 'inline' for outputConfig.sourcemap, received "${sourcemap}".` + ); + }); + }); + }); +}); diff --git a/packages/@lwc/errors/src/compiler/error-info/compiler.ts b/packages/@lwc/errors/src/compiler/error-info/compiler.ts index e4b1018886..71bf533cd8 100644 --- a/packages/@lwc/errors/src/compiler/error-info/compiler.ts +++ b/packages/@lwc/errors/src/compiler/error-info/compiler.ts @@ -62,7 +62,8 @@ export const CompilerValidationErrors = { INVALID_SOURCEMAP_PROPERTY: { code: 1021, - message: 'Expected a boolean value for outputConfig.sourcemap, received "{0}".', + message: + 'Expected a boolean value or \'inline\' for outputConfig.sourcemap, received "{0}".', level: DiagnosticLevel.Error, url: '', }, diff --git a/packages/@lwc/rollup-plugin/src/index.ts b/packages/@lwc/rollup-plugin/src/index.ts index 857a350aab..4c67d80436 100644 --- a/packages/@lwc/rollup-plugin/src/index.ts +++ b/packages/@lwc/rollup-plugin/src/index.ts @@ -22,8 +22,8 @@ export interface RollupLwcOptions { exclude?: FilterPattern; /** The LWC root module directory. */ rootDir?: string; - /** If `true` the plugin will produce source maps. */ - sourcemap?: boolean; + /** If `true` the plugin will produce source maps. If `'inline'`, the plugin will produce inlined source maps and append them to the end of the generated file. */ + sourcemap?: boolean | 'inline'; /** The [module resolution](https://lwc.dev/guide/es_modules#module-resolution) overrides passed to the `@lwc/module-resolver`. */ modules?: ModuleRecord[]; /** The stylesheet compiler configuration to pass to the `@lwc/style-compiler` */ From 8e6b4a5db9f0ddfb592a5f29466eb1676f3b62a4 Mon Sep 17 00:00:00 2001 From: Eugene Kashida Date: Tue, 5 Mar 2024 13:44:22 -0800 Subject: [PATCH 8/9] chore: avoid discarding text content whitespace (#4029) --- .../valid/text-node-adjacency/ast.json | 144 ++++++++++++++++++ .../valid/text-node-adjacency/expected.js | 22 ++- .../template-compiler/src/parser/index.ts | 18 ++- 3 files changed, 176 insertions(+), 8 deletions(-) diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/ast.json b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/ast.json index 8699fb47f6..1eebce1650 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/ast.json +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/ast.json @@ -207,6 +207,22 @@ "start": 67, "end": 79 } + }, + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 4, + "startColumn": 26, + "endLine": 4, + "endColumn": 27, + "start": 79, + "end": 80 + } } ] }, @@ -243,6 +259,22 @@ "directives": [], "listeners": [], "children": [ + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 5, + "startColumn": 14, + "endLine": 5, + "endColumn": 15, + "start": 100, + "end": 101 + } + }, { "type": "Text", "raw": "{spaceLeft}", @@ -433,6 +465,22 @@ "directives": [], "listeners": [], "children": [ + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 7, + "startColumn": 14, + "endLine": 7, + "endColumn": 15, + "start": 162, + "end": 163 + } + }, { "type": "Text", "raw": "{one}", @@ -627,6 +675,22 @@ "start": 198, "end": 203 } + }, + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 8, + "startColumn": 24, + "endLine": 8, + "endColumn": 25, + "start": 203, + "end": 204 + } } ] }, @@ -703,6 +767,22 @@ "end": 229 } }, + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 9, + "startColumn": 19, + "endLine": 9, + "endColumn": 20, + "start": 229, + "end": 230 + } + }, { "type": "Text", "raw": "{two}", @@ -778,6 +858,22 @@ "directives": [], "listeners": [], "children": [ + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 10, + "startColumn": 14, + "endLine": 10, + "endColumn": 15, + "start": 255, + "end": 256 + } + }, { "type": "Text", "raw": "{one}", @@ -818,6 +914,22 @@ "end": 261 } }, + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 10, + "startColumn": 20, + "endLine": 10, + "endColumn": 21, + "start": 261, + "end": 262 + } + }, { "type": "Text", "raw": "{two}", @@ -933,6 +1045,22 @@ "end": 292 } }, + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 11, + "startColumn": 19, + "endLine": 11, + "endColumn": 20, + "start": 292, + "end": 293 + } + }, { "type": "Text", "raw": "{two}", @@ -972,6 +1100,22 @@ "start": 293, "end": 298 } + }, + { + "type": "Text", + "raw": " ", + "value": { + "type": "Literal", + "value": " " + }, + "location": { + "startLine": 11, + "startColumn": 25, + "endLine": 11, + "endColumn": 26, + "start": 298, + "end": 299 + } } ] } diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/expected.js index 46c8438e46..6b52417268 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/valid/text-node-adjacency/expected.js @@ -34,25 +34,33 @@ function tmpl($api, $cmp, $slotset, $ctx) { return [ api_element("section", stc0, [ api_element("div", stc1, [api_text(api_dynamic_text($cmp.noSpace))]), - api_element("div", stc2, [api_text(api_dynamic_text($cmp.spaceRight))]), - api_element("div", stc3, [api_text(api_dynamic_text($cmp.spaceLeft))]), + api_element("div", stc2, [ + api_text(api_dynamic_text($cmp.spaceRight) + " "), + ]), + api_element("div", stc3, [ + api_text(" " + api_dynamic_text($cmp.spaceLeft)), + ]), api_element("div", stc4, [ api_text(api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two)), ]), api_element("div", stc5, [ - api_text(api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two)), + api_text(" " + api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two)), ]), api_element("div", stc6, [ - api_text(api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two)), + api_text(api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two) + " "), ]), api_element("div", stc7, [ - api_text(api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two)), + api_text(api_dynamic_text($cmp.one) + " " + api_dynamic_text($cmp.two)), ]), api_element("div", stc8, [ - api_text(api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two)), + api_text( + " " + api_dynamic_text($cmp.one) + " " + api_dynamic_text($cmp.two) + ), ]), api_element("div", stc9, [ - api_text(api_dynamic_text($cmp.one) + api_dynamic_text($cmp.two)), + api_text( + api_dynamic_text($cmp.one) + " " + api_dynamic_text($cmp.two) + " " + ), ]), ]), ]; diff --git a/packages/@lwc/template-compiler/src/parser/index.ts b/packages/@lwc/template-compiler/src/parser/index.ts index 340a04f760..a35e666dcf 100644 --- a/packages/@lwc/template-compiler/src/parser/index.ts +++ b/packages/@lwc/template-compiler/src/parser/index.ts @@ -467,7 +467,23 @@ function parseText(ctx: ParserCtx, parse5Text: parse5Tools.TextNode): Text[] { // Extract the raw source to avoid HTML entity decoding done by parse5 const rawText = cleanTextNode(ctx.getSource(location.startOffset, location.endOffset)); - if (!rawText.trim().length) { + /* + The original job of this if-block was to discard the whitespace between HTML tags, HTML + comments, and HTML tags and HTML comments. The whitespace inside the text content of HTML tags + would never be considered here because they would not be parsed into individual text nodes until + later (several lines below). + + ["Hello {first} {last}!"] => ["Hello ", "{first}", " ", "{last}", "!"] + + With the implementation of complex template expressions, whitespace that shouldn't be discarded + has already been parsed into individual text nodes at this point so we only discard when + experimentalComplexExpressions is disabled. + + When removing the experimentalComplexExpressions flag, we need to figure out how to best discard + the HTML whitespace while preserving text content whitespace, while also taking into account how + comments are sometimes preserved (in which case we need to keep the HTML whitespace). + */ + if (!rawText.trim().length && !ctx.config.experimentalComplexExpressions) { return parsedTextNodes; } From dff4999a535181074dfd905418bb8aaecf5cff82 Mon Sep 17 00:00:00 2001 From: Abdulsattar Mohammed Date: Thu, 7 Mar 2024 23:26:51 +0530 Subject: [PATCH 9/9] v6.3.0 (#4036) --- package.json | 2 +- packages/@lwc/aria-reflection/package.json | 2 +- .../@lwc/babel-plugin-component/package.json | 6 ++-- packages/@lwc/compiler/package.json | 12 +++---- packages/@lwc/engine-core/package.json | 8 ++--- packages/@lwc/engine-dom/package.json | 6 ++-- packages/@lwc/engine-server/package.json | 8 ++--- packages/@lwc/errors/package.json | 2 +- packages/@lwc/features/package.json | 4 +-- packages/@lwc/integration-karma/package.json | 12 +++---- packages/@lwc/integration-tests/package.json | 6 ++-- packages/@lwc/module-resolver/package.json | 2 +- .../perf-benchmarks-components/package.json | 4 +-- packages/@lwc/perf-benchmarks/package.json | 10 +++--- packages/@lwc/rollup-plugin/package.json | 8 ++--- packages/@lwc/shared/package.json | 2 +- packages/@lwc/signals/package.json | 2 +- packages/@lwc/style-compiler/package.json | 4 +-- packages/@lwc/synthetic-shadow/package.json | 6 ++-- packages/@lwc/template-compiler/package.json | 6 ++-- packages/@lwc/wire-service/package.json | 6 ++-- packages/lwc/package.json | 32 +++++++++---------- playground/package.json | 6 ++-- 23 files changed, 78 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index c118112b72..dedf8865dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lwc-monorepo", - "version": "6.2.1", + "version": "6.3.0", "private": true, "description": "Lightning Web Components", "repository": { diff --git a/packages/@lwc/aria-reflection/package.json b/packages/@lwc/aria-reflection/package.json index 988dc04409..b20d4d6242 100644 --- a/packages/@lwc/aria-reflection/package.json +++ b/packages/@lwc/aria-reflection/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/aria-reflection", - "version": "6.2.1", + "version": "6.3.0", "description": "ARIA element reflection polyfill for strings", "keywords": [ "aom", diff --git a/packages/@lwc/babel-plugin-component/package.json b/packages/@lwc/babel-plugin-component/package.json index fc376c7735..b85b95cf33 100644 --- a/packages/@lwc/babel-plugin-component/package.json +++ b/packages/@lwc/babel-plugin-component/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/babel-plugin-component", - "version": "6.2.1", + "version": "6.3.0", "description": "Babel plugin to transform a LWC module", "keywords": [ "lwc" @@ -43,8 +43,8 @@ }, "dependencies": { "@babel/helper-module-imports": "7.22.15", - "@lwc/errors": "6.2.1", - "@lwc/shared": "6.2.1", + "@lwc/errors": "6.3.0", + "@lwc/shared": "6.3.0", "line-column": "~1.0.2" }, "devDependencies": { diff --git a/packages/@lwc/compiler/package.json b/packages/@lwc/compiler/package.json index 1a84e85ccb..7ce6670d49 100755 --- a/packages/@lwc/compiler/package.json +++ b/packages/@lwc/compiler/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/compiler", - "version": "6.2.1", + "version": "6.3.0", "description": "LWC compiler", "keywords": [ "lwc" @@ -48,10 +48,10 @@ "@babel/plugin-proposal-object-rest-spread": "7.20.7", "@babel/plugin-transform-async-to-generator": "7.23.3", "@locker/babel-plugin-transform-unforgeables": "0.20.0", - "@lwc/babel-plugin-component": "6.2.1", - "@lwc/errors": "6.2.1", - "@lwc/shared": "6.2.1", - "@lwc/style-compiler": "6.2.1", - "@lwc/template-compiler": "6.2.1" + "@lwc/babel-plugin-component": "6.3.0", + "@lwc/errors": "6.3.0", + "@lwc/shared": "6.3.0", + "@lwc/style-compiler": "6.3.0", + "@lwc/template-compiler": "6.3.0" } } diff --git a/packages/@lwc/engine-core/package.json b/packages/@lwc/engine-core/package.json index bdb2fd06dd..f21ee7fa98 100644 --- a/packages/@lwc/engine-core/package.json +++ b/packages/@lwc/engine-core/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/engine-core", - "version": "6.2.1", + "version": "6.3.0", "description": "Core LWC engine APIs.", "keywords": [ "lwc" @@ -42,11 +42,11 @@ } }, "dependencies": { - "@lwc/features": "6.2.1", - "@lwc/shared": "6.2.1" + "@lwc/features": "6.3.0", + "@lwc/shared": "6.3.0" }, "devDependencies": { "observable-membrane": "2.0.0", - "@lwc/signals": "6.2.1" + "@lwc/signals": "6.3.0" } } diff --git a/packages/@lwc/engine-dom/package.json b/packages/@lwc/engine-dom/package.json index b1c793b02a..f3fa39245c 100644 --- a/packages/@lwc/engine-dom/package.json +++ b/packages/@lwc/engine-dom/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/engine-dom", - "version": "6.2.1", + "version": "6.3.0", "description": "Renders LWC components in a DOM environment.", "keywords": [ "lwc" @@ -42,8 +42,8 @@ } }, "devDependencies": { - "@lwc/engine-core": "6.2.1", - "@lwc/shared": "6.2.1" + "@lwc/engine-core": "6.3.0", + "@lwc/shared": "6.3.0" }, "lwc": { "modules": [ diff --git a/packages/@lwc/engine-server/package.json b/packages/@lwc/engine-server/package.json index b0ced1a899..86a2d14543 100644 --- a/packages/@lwc/engine-server/package.json +++ b/packages/@lwc/engine-server/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/engine-server", - "version": "6.2.1", + "version": "6.3.0", "description": "Renders LWC components in a server environment.", "keywords": [ "lwc" @@ -42,9 +42,9 @@ } }, "devDependencies": { - "@lwc/engine-core": "6.2.1", - "@lwc/rollup-plugin": "6.2.1", - "@lwc/shared": "6.2.1", + "@lwc/engine-core": "6.3.0", + "@lwc/rollup-plugin": "6.3.0", + "@lwc/shared": "6.3.0", "@rollup/plugin-virtual": "^3.0.1", "parse5": "^7.1.2", "@parse5/tools": "^0.3.0" diff --git a/packages/@lwc/errors/package.json b/packages/@lwc/errors/package.json index ec2eaf9f7f..a6d83667ce 100644 --- a/packages/@lwc/errors/package.json +++ b/packages/@lwc/errors/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/errors", - "version": "6.2.1", + "version": "6.3.0", "description": "LWC Error Utilities", "keywords": [ "lwc" diff --git a/packages/@lwc/features/package.json b/packages/@lwc/features/package.json index 57aa72f3f3..d5a9d83114 100644 --- a/packages/@lwc/features/package.json +++ b/packages/@lwc/features/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/features", - "version": "6.2.1", + "version": "6.3.0", "description": "LWC Features Flags", "keywords": [ "lwc" @@ -42,6 +42,6 @@ } }, "dependencies": { - "@lwc/shared": "6.2.1" + "@lwc/shared": "6.3.0" } } diff --git a/packages/@lwc/integration-karma/package.json b/packages/@lwc/integration-karma/package.json index 4cb4f13d97..9270cbef8f 100644 --- a/packages/@lwc/integration-karma/package.json +++ b/packages/@lwc/integration-karma/package.json @@ -1,7 +1,7 @@ { "name": "@lwc/integration-karma", "private": true, - "version": "6.2.1", + "version": "6.3.0", "scripts": { "start": "KARMA_MODE=watch karma start ./scripts/karma-configs/test/local.js", "test": "karma start ./scripts/karma-configs/test/local.js --single-run --browsers ChromeHeadless", @@ -17,12 +17,12 @@ "karma-sauce-launcher-fix-firefox": "using a fork to work around https://github.com/karma-runner/karma-sauce-launcher/issues/275" }, "devDependencies": { - "@lwc/compiler": "6.2.1", - "@lwc/engine-dom": "6.2.1", - "@lwc/engine-server": "6.2.1", - "@lwc/rollup-plugin": "6.2.1", + "@lwc/compiler": "6.3.0", + "@lwc/engine-dom": "6.3.0", + "@lwc/engine-server": "6.3.0", + "@lwc/rollup-plugin": "6.3.0", "@lwc/rollup-plugin-v5": "npm:@lwc/rollup-plugin@5.3.0", - "@lwc/synthetic-shadow": "6.2.1", + "@lwc/synthetic-shadow": "6.3.0", "chokidar": "^3.5.3", "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", diff --git a/packages/@lwc/integration-tests/package.json b/packages/@lwc/integration-tests/package.json index 471db3f3fd..b3cafff5f3 100644 --- a/packages/@lwc/integration-tests/package.json +++ b/packages/@lwc/integration-tests/package.json @@ -1,7 +1,7 @@ { "name": "@lwc/integration-tests", "private": true, - "version": "6.2.1", + "version": "6.3.0", "scripts": { "build": "node scripts/build.js", "build:dev": "MODE=dev yarn build", @@ -16,7 +16,7 @@ "sauce:prod:ci": "MODE=prod yarn build:prod && MODE=prod ../../../scripts/ci/retry.sh wdio ./scripts/wdio.sauce.conf.js" }, "devDependencies": { - "@lwc/rollup-plugin": "6.2.1", + "@lwc/rollup-plugin": "6.3.0", "@wdio/cli": "^8.29.3", "@wdio/local-runner": "^8.29.3", "@wdio/mocha-framework": "^8.29.3", @@ -25,7 +25,7 @@ "@wdio/static-server-service": "^8.29.1", "deepmerge": "^4.3.0", "dotenv": "^16.4.5", - "lwc": "6.2.1", + "lwc": "6.3.0", "minimist": "^1.2.8", "webdriverio": "^8.29.3" } diff --git a/packages/@lwc/module-resolver/package.json b/packages/@lwc/module-resolver/package.json index d6db885866..93303e9b7e 100644 --- a/packages/@lwc/module-resolver/package.json +++ b/packages/@lwc/module-resolver/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/module-resolver", - "version": "6.2.1", + "version": "6.3.0", "description": "Resolves paths for LWC components", "keywords": [ "lwc" diff --git a/packages/@lwc/perf-benchmarks-components/package.json b/packages/@lwc/perf-benchmarks-components/package.json index 517a0b9a3f..6a37883ffd 100644 --- a/packages/@lwc/perf-benchmarks-components/package.json +++ b/packages/@lwc/perf-benchmarks-components/package.json @@ -1,12 +1,12 @@ { "name": "@lwc/perf-benchmarks-components", - "version": "6.2.1", + "version": "6.3.0", "private": true, "scripts": { "build": "rm -fr dist && rollup -c ./rollup.config.mjs" }, "devDependencies": { - "@lwc/rollup-plugin": "6.2.1" + "@lwc/rollup-plugin": "6.3.0" }, "nx": { "targets": { diff --git a/packages/@lwc/perf-benchmarks/package.json b/packages/@lwc/perf-benchmarks/package.json index ba19a03719..679b2e598e 100644 --- a/packages/@lwc/perf-benchmarks/package.json +++ b/packages/@lwc/perf-benchmarks/package.json @@ -1,6 +1,6 @@ { "name": "@lwc/perf-benchmarks", - "version": "6.2.1", + "version": "6.3.0", "private": true, "scripts": { "build": "rm -fr dist && rollup -c ./rollup.config.mjs && node scripts/build.js && ./scripts/fix-deps.sh", @@ -17,10 +17,10 @@ "Also note that we use legacy versions of rollup-plugin-node-resolve and rollup-plugin-commonjs because Best uses an old version of Rollup." ], "dependencies": { - "@lwc/engine-dom": "6.2.1", - "@lwc/engine-server": "6.2.1", - "@lwc/perf-benchmarks-components": "6.2.1", - "@lwc/synthetic-shadow": "6.2.1" + "@lwc/engine-dom": "6.3.0", + "@lwc/engine-server": "6.3.0", + "@lwc/perf-benchmarks-components": "6.3.0", + "@lwc/synthetic-shadow": "6.3.0" }, "devDependencies": { "@best/cli": "^11.0.0", diff --git a/packages/@lwc/rollup-plugin/package.json b/packages/@lwc/rollup-plugin/package.json index 1691cb19a1..b7c4444792 100644 --- a/packages/@lwc/rollup-plugin/package.json +++ b/packages/@lwc/rollup-plugin/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/rollup-plugin", - "version": "6.2.1", + "version": "6.3.0", "description": "Rollup plugin to compile LWC", "keywords": [ "lwc" @@ -42,12 +42,12 @@ } }, "dependencies": { - "@lwc/compiler": "6.2.1", - "@lwc/module-resolver": "6.2.1", + "@lwc/compiler": "6.3.0", + "@lwc/module-resolver": "6.3.0", "@rollup/pluginutils": "~5.1.0" }, "devDependencies": { - "@lwc/errors": "6.2.1" + "@lwc/errors": "6.3.0" }, "peerDependencies": { "rollup": "^1.2.0||^2.0.0||^3.0.0||^4.0.0" diff --git a/packages/@lwc/shared/package.json b/packages/@lwc/shared/package.json index a6c4859607..04c71a75a3 100644 --- a/packages/@lwc/shared/package.json +++ b/packages/@lwc/shared/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/shared", - "version": "6.2.1", + "version": "6.3.0", "description": "Utilities and methods that are shared across packages", "keywords": [ "lwc" diff --git a/packages/@lwc/signals/package.json b/packages/@lwc/signals/package.json index 4dfa34c38e..4ddc10ec58 100644 --- a/packages/@lwc/signals/package.json +++ b/packages/@lwc/signals/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/signals", - "version": "6.2.1", + "version": "6.3.0", "description": "Provides the interface to interact with reactivity from outside the framework", "keywords": [ "lwc" diff --git a/packages/@lwc/style-compiler/package.json b/packages/@lwc/style-compiler/package.json index 6aa6187583..4be7ce9214 100644 --- a/packages/@lwc/style-compiler/package.json +++ b/packages/@lwc/style-compiler/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/style-compiler", - "version": "6.2.1", + "version": "6.3.0", "description": "Transform style sheet to be consumed by the LWC engine", "keywords": [ "lwc" @@ -42,7 +42,7 @@ } }, "dependencies": { - "@lwc/shared": "6.2.1", + "@lwc/shared": "6.3.0", "postcss": "~8.4.35", "postcss-selector-parser": "~6.0.15", "postcss-value-parser": "~4.2.0" diff --git a/packages/@lwc/synthetic-shadow/package.json b/packages/@lwc/synthetic-shadow/package.json index da3cb51e5b..12dba97e04 100644 --- a/packages/@lwc/synthetic-shadow/package.json +++ b/packages/@lwc/synthetic-shadow/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/synthetic-shadow", - "version": "6.2.1", + "version": "6.3.0", "description": "Synthetic Shadow Root for LWC", "keywords": [ "lwc" @@ -42,8 +42,8 @@ } }, "devDependencies": { - "@lwc/features": "6.2.1", - "@lwc/shared": "6.2.1" + "@lwc/features": "6.3.0", + "@lwc/shared": "6.3.0" }, "lwc": { "modules": [ diff --git a/packages/@lwc/template-compiler/package.json b/packages/@lwc/template-compiler/package.json index ddc23bfdfb..1f21456aa7 100644 --- a/packages/@lwc/template-compiler/package.json +++ b/packages/@lwc/template-compiler/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/template-compiler", - "version": "6.2.1", + "version": "6.3.0", "description": "Template compiler package", "keywords": [ "lwc" @@ -42,8 +42,8 @@ } }, "dependencies": { - "@lwc/errors": "6.2.1", - "@lwc/shared": "6.2.1", + "@lwc/errors": "6.3.0", + "@lwc/shared": "6.3.0", "acorn": "8.10.0", "astring": "~1.8.6", "estree-walker": "~2.0.2", diff --git a/packages/@lwc/wire-service/package.json b/packages/@lwc/wire-service/package.json index 552beab560..59539f93b9 100644 --- a/packages/@lwc/wire-service/package.json +++ b/packages/@lwc/wire-service/package.json @@ -4,7 +4,7 @@ "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten." ], "name": "@lwc/wire-service", - "version": "6.2.1", + "version": "6.3.0", "description": "@wire service", "keywords": [ "lwc" @@ -42,8 +42,8 @@ } }, "devDependencies": { - "@lwc/engine-core": "6.2.1", - "@lwc/shared": "6.2.1" + "@lwc/engine-core": "6.3.0", + "@lwc/shared": "6.3.0" }, "lwc": { "modules": [ diff --git a/packages/lwc/package.json b/packages/lwc/package.json index 67b1372ddc..ce9ebf977f 100644 --- a/packages/lwc/package.json +++ b/packages/lwc/package.json @@ -1,6 +1,6 @@ { "name": "lwc", - "version": "6.2.1", + "version": "6.3.0", "description": "Lightning Web Components (LWC)", "homepage": "https://lwc.dev/", "repository": { @@ -20,21 +20,21 @@ "*.d.ts" ], "dependencies": { - "@lwc/aria-reflection": "6.2.1", - "@lwc/babel-plugin-component": "6.2.1", - "@lwc/compiler": "6.2.1", - "@lwc/engine-core": "6.2.1", - "@lwc/engine-dom": "6.2.1", - "@lwc/engine-server": "6.2.1", - "@lwc/errors": "6.2.1", - "@lwc/features": "6.2.1", - "@lwc/module-resolver": "6.2.1", - "@lwc/rollup-plugin": "6.2.1", - "@lwc/shared": "6.2.1", - "@lwc/style-compiler": "6.2.1", - "@lwc/synthetic-shadow": "6.2.1", - "@lwc/template-compiler": "6.2.1", - "@lwc/wire-service": "6.2.1" + "@lwc/aria-reflection": "6.3.0", + "@lwc/babel-plugin-component": "6.3.0", + "@lwc/compiler": "6.3.0", + "@lwc/engine-core": "6.3.0", + "@lwc/engine-dom": "6.3.0", + "@lwc/engine-server": "6.3.0", + "@lwc/errors": "6.3.0", + "@lwc/features": "6.3.0", + "@lwc/module-resolver": "6.3.0", + "@lwc/rollup-plugin": "6.3.0", + "@lwc/shared": "6.3.0", + "@lwc/style-compiler": "6.3.0", + "@lwc/synthetic-shadow": "6.3.0", + "@lwc/template-compiler": "6.3.0", + "@lwc/wire-service": "6.3.0" }, "lwc": { "modules": [ diff --git a/playground/package.json b/playground/package.json index a326db7560..491891517e 100644 --- a/playground/package.json +++ b/playground/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@lwc/playground", - "version": "6.2.1", + "version": "6.3.0", "type": "module", "description": "Playground project to experiment with LWC.", "scripts": { @@ -9,9 +9,9 @@ "build": "NODE_ENV=production rollup -c" }, "devDependencies": { - "@lwc/rollup-plugin": "6.2.1", + "@lwc/rollup-plugin": "6.3.0", "@rollup/plugin-replace": "^5.0.5", - "lwc": "6.2.1", + "lwc": "6.3.0", "rollup": "^4.9.6", "rollup-plugin-livereload": "^2.0.5", "rollup-plugin-serve": "^3.0.0"