diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.hydrate.js index 32b34ab56..c250fc1e9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.hydrate.js @@ -1,7 +1,6 @@ -// size: 163 (min) 122 (brotli) +// size: 157 (min) 117 (brotli) const $foo = _._let(3, ($scope, foo) => { - (_._attr_class($scope[0], foo.class), - _._attr_class($scope[1], foo.class.class)); + (_._attr_class($scope[0], foo.class), _._attr_class($scope[1], foo.class)); }); (_._script("a0", ($scope) => _._on($scope[2], "click", function () { diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.js index 889344d0d..b9f9977d8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/dom.expected/template.js @@ -3,7 +3,7 @@ export const $walks = /* get, over(1), get, over(1), get, over(1) */" b b b"; import * as _ from "@marko/runtime-tags/debug/dom"; const $foo = /* @__PURE__ */_._let("foo/3", ($scope, foo) => { _._attr_class($scope["#div/0"], (foo, foo.class)); - _._attr_class($scope["#div/1"], (foo, foo.class.class)); + _._attr_class($scope["#div/1"], (foo, foo.class)); }); const $setup__script = _._script("__tests__/template.marko_0", $scope => _._on($scope["#button/2"], "click", function () { $foo($scope, { diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/html.expected/template.js index 8177aa111..a39a89806 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/html.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-merge-member-expression/__snapshots__/html.expected/template.js @@ -5,7 +5,7 @@ export default _._template("__tests__/template.marko", input => { const { class: fooClass } = foo; - _._html(`${_._el_resume($scope0_id, "#div/0")}${_._el_resume($scope0_id, "#div/1")}${_._el_resume($scope0_id, "#button/2")}`); + _._html(`${_._el_resume($scope0_id, "#div/0")}${_._el_resume($scope0_id, "#div/1")}${_._el_resume($scope0_id, "#button/2")}`); _._script($scope0_id, "__tests__/template.marko_0"); _._scope($scope0_id, {}, "__tests__/template.marko", 0); _._resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.hydrate.js index 93f70f46e..435cf8021 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 531 (min) 298 (brotli) +// size: 530 (min) 290 (brotli) const $name = _._const(3, ($scope, name) => _._text($scope[0], name)), $for_content2__setup = ($scope) => { ($scope[0], $for_content2__outer._($scope)); @@ -39,7 +39,7 @@ const $name = _._const(3, ($scope, name) => _._text($scope[0], name)), $for = _._for_of(1, $for_content), $items__script = _._script("b0", ($scope, { 2: items }) => _._on($scope[0], "click", function () { - $items($scope, (items = [...items, items?.length])); + $items($scope, (items = [...items, items.length])); }), ), $items = _._let(2, ($scope, items) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.js index 4f9c41c1f..067179f43 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-for/__snapshots__/dom.expected/template.js @@ -29,7 +29,7 @@ const $for = /* @__PURE__ */_._for_of("#text/1", $for_content); const $items__script = _._script("__tests__/template.marko_0_items", ($scope, { items }) => _._on($scope["#button/0"], "click", function () { - $items($scope, items = [...items, items?.length]); + $items($scope, items = [...items, items.length]); })); const $items = /* @__PURE__ */_._let("items/2", ($scope, items) => { $for($scope, [items]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js index 004ca5441..a191b33de 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 665 (min) 359 (brotli) +// size: 664 (min) 356 (brotli) const $name__OR__write__script = _._script( "a0", ($scope, { 5: name, 6: write }) => { @@ -37,7 +37,7 @@ const $name__OR__write__script = _._script( $for = _._for_of(2, $for_content), $items__script = _._script("b1", ($scope, { 3: items }) => _._on($scope[0], "click", function () { - $items($scope, (items = items?.length ? items.slice(0, -1) : [1, 2, 3])); + $items($scope, (items = items.length ? items.slice(0, -1) : [1, 2, 3])); }), ), $items = _._let(3, ($scope, items) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.js index a09383558..f18d69914 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/cleanup-n-child-for-shallow/__snapshots__/dom.expected/template.js @@ -14,7 +14,7 @@ const $for = /* @__PURE__ */_._for_of("#text/2", $for_content); const $items__script = _._script("__tests__/template.marko_0_items", ($scope, { items }) => _._on($scope["#button/0"], "click", function () { - $items($scope, items = items?.length ? items.slice(0, -1) : [1, 2, 3]); + $items($scope, items = items.length ? items.slice(0, -1) : [1, 2, 3]); })); const $items = /* @__PURE__ */_._let("items/3", ($scope, items) => { $for($scope, [items]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.hydrate.js index 1e778058d..e79832c4b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 938 (min) 447 (brotli) +// size: 937 (min) 445 (brotli) const $name__OR__write__script = _._script( "a0", ($scope, { 3: name, 4: write }) => @@ -73,7 +73,7 @@ const $name__OR__write__script = _._script( $for = _._for_of(2, $for_content), $items__script = _._script("b1", ($scope, { 3: items }) => _._on($scope[0], "click", function () { - $items($scope, (items = items?.length ? items.slice(0, -1) : [1, 2, 3])); + $items($scope, (items = items.length ? items.slice(0, -1) : [1, 2, 3])); }), ), $items = _._let(3, ($scope, items) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.js index 14911acde..011c41a6c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-deep/__snapshots__/dom.expected/template.js @@ -39,7 +39,7 @@ const $for = /* @__PURE__ */_._for_of("#text/2", $for_content); const $items__script = _._script("__tests__/template.marko_0_items", ($scope, { items }) => _._on($scope["#button/0"], "click", function () { - $items($scope, items = items?.length ? items.slice(0, -1) : [1, 2, 3]); + $items($scope, items = items.length ? items.slice(0, -1) : [1, 2, 3]); })); const $items = /* @__PURE__ */_._let("items/3", ($scope, items) => { $for($scope, [items]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js index bbe733b24..7ce12ef63 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 605 (min) 336 (brotli) +// size: 604 (min) 336 (brotli) const $name__OR__write__script = _._script( "a0", ($scope, { 3: name, 4: write }) => { @@ -34,7 +34,7 @@ const $name__OR__write__script = _._script( $for = _._for_of(2, $for_content), $items__script = _._script("b1", ($scope, { 3: items }) => _._on($scope[0], "click", function () { - $items($scope, (items = items?.length ? items.slice(0, -1) : [1, 2, 3])); + $items($scope, (items = items.length ? items.slice(0, -1) : [1, 2, 3])); }), ), $items = _._let(3, ($scope, items) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.js index a09383558..f18d69914 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/cleanup-single-child-for-shallow/__snapshots__/dom.expected/template.js @@ -14,7 +14,7 @@ const $for = /* @__PURE__ */_._for_of("#text/2", $for_content); const $items__script = _._script("__tests__/template.marko_0_items", ($scope, { items }) => _._on($scope["#button/0"], "click", function () { - $items($scope, items = items?.length ? items.slice(0, -1) : [1, 2, 3]); + $items($scope, items = items.length ? items.slice(0, -1) : [1, 2, 3]); })); const $items = /* @__PURE__ */_._let("items/3", ($scope, items) => { $for($scope, [items]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.hydrate.js index c6215ed6e..7bb6ce8ee 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 630 (min) 326 (brotli) +// size: 627 (min) 306 (brotli) const $for_content__opt = _._const(3, ($scope, opt) => { (_._attr($scope[0], "value", opt), _._text($scope[1], opt)); }), @@ -19,7 +19,7 @@ const $for_content__opt = _._const(3, ($scope, opt) => { _._on($scope[3], "click", function () { $options( $scope, - (options = [options?.length ? options?.[0] - 1 : 3, ...options]), + (options = [options.length ? options[0] - 1 : 3, ...options]), ); })); }), diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.js index da41fd9a3..1856a9977 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-mutated-option/__snapshots__/dom.expected/template.js @@ -15,7 +15,7 @@ const $options__script = _._script("__tests__/template.marko_0_options", ($scope $options($scope, options = options.slice(1)); }); _._on($scope["#button/3"], "click", function () { - $options($scope, options = [options?.length ? options?.[0] - 1 : 3, ...options]); + $options($scope, options = [options.length ? options[0] - 1 : 3, ...options]); }); }); const $options = /* @__PURE__ */_._let("options/4", ($scope, options) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.hydrate.js index 295061999..766574af6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 975 (min) 282 (brotli) +// size: 973 (min) 295 (brotli) const $for_content5__text = _._const(3, ($scope, text) => _._text($scope[0], text), ), @@ -48,7 +48,7 @@ const $for_content5__text = _._const(3, ($scope, text) => $for5 = _._for_of(4, $for_content5), $items__script = _._script("a0", ($scope, { 6: items }) => _._on($scope[5], "click", function () { - $items($scope, (items = [...items.slice(1), items?.[0]])); + $items($scope, (items = [...items.slice(1), items[0]])); }), ), $items = _._let(6, ($scope, items) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.js index 1de1c9993..d5e9f278b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/dom.expected/template.js @@ -38,7 +38,7 @@ const $for5 = /* @__PURE__ */_._for_of("#div/4", $for_content5); const $items__script = _._script("__tests__/template.marko_0_items", ($scope, { items }) => _._on($scope["#button/5"], "click", function () { - $items($scope, items = [...items.slice(1), items?.[0]]); + $items($scope, items = [...items.slice(1), items[0]]); })); const $items = /* @__PURE__ */_._let("items/6", ($scope, items) => { $for($scope, [items, "id"]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.hydrate.js index ea178c369..880d3ed91 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.hydrate.js @@ -1,8 +1,8 @@ -// size: 231 (min) 165 (brotli) +// size: 230 (min) 167 (brotli) const $for_content = _._content_branch("
", "b"), $for = _._for_of(0, $for_content), $children__script = _._script("a0", ($scope, { 1: children }) => { - 1 === children?.length && $children($scope, (children = [...children, 2])); + 1 === children.length && $children($scope, (children = [...children, 2])); }), $children = _._let(1, ($scope, children) => { ($children_length($scope, children?.length), diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.js index 09fed5342..07655d614 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-node-only-child-in-parent/__snapshots__/dom.expected/template.js @@ -6,7 +6,7 @@ const $for = /* @__PURE__ */_._for_of("#div/0", $for_content); const $children__script = _._script("__tests__/template.marko_0_children", ($scope, { children }) => { - if (children?.length === 1) { + if (children.length === 1) { $children($scope, children = [...children, 2]); } }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.hydrate.js index dff180afd..1da7ced3e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.hydrate.js @@ -1,8 +1,8 @@ -// size: 225 (min) 170 (brotli) +// size: 224 (min) 170 (brotli) const $for_content = _._content_branch("Child", "b"), $for = _._for_of(1, $for_content), $children__script = _._script("a0", ($scope, { 2: children }) => { - 1 === children?.length && $children($scope, (children = [...children, 2])); + 1 === children.length && $children($scope, (children = [...children, 2])); }), $children = _._let(2, ($scope, children) => { ($children_length($scope, children?.length), diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.js index 206f98d4d..9aa279e85 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-single-text-node-with-text-before/__snapshots__/dom.expected/template.js @@ -6,7 +6,7 @@ const $for = /* @__PURE__ */_._for_of("#text/1", $for_content); const $children__script = _._script("__tests__/template.marko_0_children", ($scope, { children }) => { - if (children?.length === 1) { + if (children.length === 1) { $children($scope, children = [...children, 2]); } }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.hydrate.js index 2460ff4b4..12c2c3713 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.hydrate.js @@ -1,6 +1,6 @@ -// size: 106 (min) 99 (brotli) +// size: 105 (min) 95 (brotli) (_._script("a1", ($scope, { 2: baz }) => ($scope[0].textContent = baz.bar())), _._resume("a0", function ({ 1: foo }) { - return () => foo?.bar; + return () => foo.bar; }), init()); diff --git a/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.js index 2c59267b4..16f656bf4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/dom.expected/template.js @@ -17,7 +17,7 @@ export function $setup($scope) { function $baz({ foo }) { - return () => foo?.bar; + return () => foo.bar; } _._resume("__tests__/template.marko_0/baz", $baz); export default /* @__PURE__ */_._template("__tests__/template.marko", $template, $walks, $setup); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/html.expected/template.js index 696c3dcc4..f87b5454c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/html.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/function-references-normalize/__snapshots__/html.expected/template.js @@ -6,7 +6,7 @@ export default _._template("__tests__/template.marko", input => { }; const baz = { foo, - bar: _._resume(() => foo?.bar, "__tests__/template.marko_0/baz", $scope0_id) + bar: _._resume(() => foo.bar, "__tests__/template.marko_0/baz", $scope0_id) }; _._html(`
${_._el_resume($scope0_id, "#div/0")}`); _._script($scope0_id, "__tests__/template.marko_0_baz"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.hydrate.js index c52cfccea..bfca73394 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 332 (min) 217 (brotli) +// size: 331 (min) 214 (brotli) const $for_content__item = _._const(2, ($scope, item) => _._text($scope[0], item), ), @@ -15,7 +15,7 @@ const $for_content__item = _._const(2, ($scope, item) => $for = _._for_of(1, $for_content), $items__script = _._script("a1", ($scope, { 2: items }) => _._on($scope[0], "click", function () { - $items($scope, (items = [...items, items?.length])); + $items($scope, (items = [...items, items.length])); }), ), $items = _._let(2, ($scope, items) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.js index a31f5e34c..be2e713a6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/getter-on-single-node-only-child/__snapshots__/dom.expected/template.js @@ -9,7 +9,7 @@ const $for = /* @__PURE__ */_._for_of("#ul/1", $for_content); const $items__script = _._script("__tests__/template.marko_0_items", ($scope, { items }) => _._on($scope["#button/0"], "click", function () { - $items($scope, items = [...items, items?.length]); + $items($scope, items = [...items, items.length]); })); const $items = /* @__PURE__ */_._let("items/2", ($scope, items) => { $for($scope, [items]); diff --git a/packages/runtime-tags/src/translator/util/references.ts b/packages/runtime-tags/src/translator/util/references.ts index 6ccb0e9dc..e331c8b20 100644 --- a/packages/runtime-tags/src/translator/util/references.ts +++ b/packages/runtime-tags/src/translator/util/references.ts @@ -1584,14 +1584,16 @@ export function getReadReplacement( } if (replaceMember) { - if (read.binding.nullable) { - replaceMember.type = "OptionalMemberExpression"; - replaceMember.optional = true; + if (replaceMember.object.type !== replacement.type) { + if (read.binding.nullable) { + replaceMember.type = "OptionalMemberExpression"; + replaceMember.optional = true; + } + replaceMember.object = withPreviousLocation( + replacement, + replaceMember.object, + ); } - replaceMember.object = withPreviousLocation( - replacement, - replaceMember.object, - ); replacement = undefined; } } @@ -1768,9 +1770,8 @@ function resolveExpressionReference( let curBinding = readBinding; let props: Opt; while (curBinding !== upstreamRoot) { - const prop = getCanonicalProperty(curBinding); - if (prop !== undefined) { - props = push(props, prop); + if (curBinding.property !== undefined) { + props = push(props, curBinding.property); } curBinding = curBinding.upstreamAlias!; @@ -1792,16 +1793,6 @@ function isSupersetSources(a: Binding, b: Binding) { ); } -function getCanonicalProperty(binding: Binding) { - if (binding.property !== undefined) { - return binding.property; - } - - if (binding.upstreamAlias && binding.excludeProperties === undefined) { - return binding.upstreamAlias.property; - } -} - function createRead(binding: Binding, props: Opt) { return { binding, props }; }