From 55e6118c8e5233339144a0fdfdd91a984d8ac0b0 Mon Sep 17 00:00:00 2001 From: James Tu Date: Mon, 11 Mar 2024 15:49:13 -0700 Subject: [PATCH 01/10] refactor: move data bag collection to after static content check --- packages/@lwc/template-compiler/src/codegen/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/@lwc/template-compiler/src/codegen/index.ts b/packages/@lwc/template-compiler/src/codegen/index.ts index 38d6d4431d..f6abf5ff53 100644 --- a/packages/@lwc/template-compiler/src/codegen/index.ts +++ b/packages/@lwc/template-compiler/src/codegen/index.ts @@ -79,14 +79,13 @@ import { format as formatModule } from './formatters/module'; function transform(codeGen: CodeGen): t.Expression { const instrumentation = codeGen.state.config.instrumentation; function transformElement(element: BaseElement, slotParentName?: string): t.Expression { - const databag = elementDataBag(element, slotParentName); - let res: t.Expression; - if (codeGen.staticNodes.has(element) && isElement(element)) { // do not process children of static nodes. return codeGen.genStaticElement(element as StaticElement, slotParentName); } + let res: t.Expression; + const databag = elementDataBag(element, slotParentName); const children = transformChildren(element); const { name } = element; From 1a7aa35e663c790b3ab6cd532b3e838de5d85af8 Mon Sep 17 00:00:00 2001 From: James Tu Date: Mon, 11 Mar 2024 15:49:32 -0700 Subject: [PATCH 02/10] chore: update all test fixtures --- .../attributes/attribute-allow/expected.js | 2 +- .../attribute-crossorigin/expected.js | 6 +-- .../attributes/attribute-part/expected.js | 2 +- .../hidden-global-attr/expected.js | 20 +++++----- .../boolean-attribute/required/expected.js | 20 +++++----- .../boolean-attributes-valid/expected.js | 6 +-- .../fixtures/attributes/boolean/expected.js | 4 +- .../fixtures/attributes/class/expected.js | 8 ++-- .../attributes/dataset-complex/expected.js | 2 +- .../fixtures/attributes/dataset/expected.js | 2 +- .../attributes/error-empty-value/expected.js | 4 +- .../fixtures/attributes/escaped/expected.js | 2 +- .../attributes/html-input/expected.js | 2 +- .../attributes/html-tag-invalid/expected.js | 2 +- .../fixtures/attributes/html-tag/expected.js | 2 +- .../attributes/mixed-props-attrs/expected.js | 12 +++--- .../expected.js | 2 +- .../__tests__/fixtures/base/class/expected.js | 2 +- .../fixtures/base/html-entities/expected.js | 4 +- .../fixtures/base/style-important/expected.js | 2 +- .../fixtures/base/style-static/expected.js | 4 +- .../fixtures/base/template/expected.js | 2 +- .../fixtures/comments/basic/expected.js | 2 +- .../comments/directive-if/expected.js | 4 +- .../preserve-html-comments-option/expected.js | 2 +- .../fixtures/comments/slots/expected.js | 2 +- .../directive-dynamic/sibbling/expected.js | 6 +-- .../directive-for-each/children/expected.js | 16 ++++---- .../inline-sibling/expected.js | 2 +- .../directive-for-each/inline/expected.js | 2 +- .../dynamic-component/expected.js | 6 +-- .../inline-both-standard-element/expected.js | 2 +- .../directive-if/inline-multiple/expected.js | 6 +-- .../inline-sibling-static/expected.js | 4 +- .../directive-if/strict-true/expected.js | 2 +- .../directive-if/template-both/expected.js | 2 +- .../directive-if/template-if-else/expected.js | 4 +- .../template-multiple/expected.js | 6 +-- .../template-sibiling/expected.js | 6 +-- .../outside-iterator/expected.js | 2 +- .../dynamic-components/if-else/expected.js | 4 +- .../if-elseif-else-nested/expected.js | 16 ++++---- .../if-elseif-else/expected.js | 6 +-- .../if-elseif-multiple/expected.js | 8 ++-- .../dynamic-components/if-elseif/expected.js | 4 +- .../dynamic-components/inline/expected.js | 10 ++--- .../dynamic/if-else/expected.js | 4 +- .../dynamic/if-elseif-else-nested/expected.js | 16 ++++---- .../dynamic/if-elseif-else/expected.js | 6 +-- .../dynamic/if-elseif-multiple/expected.js | 8 ++-- .../dynamic/if-elseif/expected.js | 4 +- .../if-else/html-elements/expected.js | 4 +- .../if-elseif-else/html-elements/expected.js | 6 +-- .../if-elseif/html-elements/expected.js | 4 +- .../if-only/html-elements/expected.js | 2 +- .../mixed-elements/expected.js | 4 +- .../simple/expected.js | 6 +-- .../with-siblings/expected.js | 10 ++--- .../static-container/expected.js | 2 +- .../fixtures/directive-ref/valid/expected.js | 2 +- .../shadow-template/expected.js | 2 +- .../template/expected.js | 8 ++-- .../valid/children/expected.js | 2 +- .../valid/nested/expected.js | 6 +-- .../valid/siblings/expected.js | 6 +-- .../fixtures/events/static/expected.js | 2 +- .../__tests__/fixtures/events/tag/expected.js | 2 +- .../fixtures/events/type-valid/expected.js | 18 ++++----- .../valid/assignment-inside-arrow/expected.js | 2 +- .../valid/iterator/expected.js | 6 +-- .../valid/update-inside-arrow/expected.js | 2 +- .../expression/empty-paranthesis/expected.js | 4 +- .../fixtures/expression/escaped/expected.js | 2 +- .../quoted-empty-paranthesis/expected.js | 4 +- .../html-tags/unkown-element/expected.js | 8 ++-- .../fixtures/lwc-tags/invalid/expected.js | 2 +- .../double-close-div/expected.js | 2 +- .../expected.js | 2 +- .../stranded-open-svg-ellipse/expected.js | 2 +- .../attribute-with-equal/expected.js | 2 +- .../regression/dashed-html-tag/expected.js | 2 +- .../keygen/expected.js | 4 +- .../menuitem/expected.js | 2 +- .../param/expected.js | 2 +- .../handler-memoization/expected.js | 12 +++--- .../invalid-html-recovery/expected.js | 4 +- .../slot-name-with-dash/expected.js | 2 +- .../regression/table-with-tr/expected.js | 2 +- .../config/multiple-tagname/expected.js | 12 +++--- .../config/tag-with-namespace/expected.js | 2 +- .../tagname-with-attributes/expected.js | 2 +- .../parent-mixed-slot-content/expected.js | 2 +- .../text-non-direct-child/expected.js | 2 +- .../definition-sibiling-slot/expected.js | 6 +-- .../definition-sibling-static/expected.js | 6 +-- .../fixtures/slots/definition/expected.js | 2 +- .../fixtures/slots/mixed-1/expected.js | 16 ++++---- .../fixtures/slots/mixed/expected.js | 2 +- .../fixtures/slots/usage-named/expected.js | 2 +- .../fixtures/slots/usage/expected.js | 20 +++++----- .../static-content/attr-escaping/expected.js | 2 +- .../class-attr-escaping/expected.js | 2 +- .../comment-escaping/expected.js | 2 +- .../deep-data-ref-only/expected.js | 2 +- .../static-content/deep-data/expected.js | 2 +- .../no-escaping-tags/expected.js | 8 ++-- .../static-content/no-th-or-td/expected.js | 8 ++-- .../expected.js | 2 +- .../preserve-comments-off/expected.js | 2 +- .../expected.js | 2 +- .../preserve-comments-on/expected.js | 2 +- .../static-content/shallow-data/expected.js | 6 +-- .../static-content/svg-within-div/expected.js | 2 +- .../static-content/svg-within-g/expected.js | 2 +- .../fixtures/static-content/svg/expected.js | 2 +- .../template-string-escape/expected.js | 24 +++++------ .../static-content/text-escaping/expected.js | 2 +- .../__tests__/fixtures/svg/filter/expected.js | 40 +++++++++---------- .../fixtures/svg/foreign-object/expected.js | 2 +- .../fixtures/svg/linear-gradient/expected.js | 6 +-- .../fixtures/svg/simple-svg/expected.js | 2 +- .../svg/stranded-open-path/expected.js | 2 +- .../fixtures/svg/valid-image/expected.js | 2 +- .../fixtures/svg/valid-svg/expected.js | 2 +- 124 files changed, 315 insertions(+), 315 deletions(-) diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-allow/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-allow/expected.js index 59c0fbe8e6..e26ce8effd 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-allow/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-allow/expected.js @@ -2,7 +2,7 @@ import { parseFragment, registerTemplate } from "lwc"; const $fragment1 = parseFragment``; function tmpl($api, $cmp, $slotset, $ctx) { const { st: api_static_fragment } = $api; - return [api_static_fragment($fragment1(), 1)]; + return [api_static_fragment($fragment1(), 0)]; /*LWC compiler vX.X.X*/ } export default registerTemplate(tmpl); diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-crossorigin/expected.js b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-crossorigin/expected.js index 21db94db2c..f631fd92a6 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-crossorigin/expected.js +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures/attributes/attribute-crossorigin/expected.js @@ -5,9 +5,9 @@ const $fragment3 = parseFragment`