diff --git a/.changeset/witty-pugs-repeat.md b/.changeset/witty-pugs-repeat.md new file mode 100644 index 00000000000..6caf6ef3bfc --- /dev/null +++ b/.changeset/witty-pugs-repeat.md @@ -0,0 +1,5 @@ +--- +"@marko/runtime-tags": patch +--- + +Fix a placeholder that renders empty resuming as another node when it follows a node with text after it, or starts a section's content diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.debug.js index e43a59fb662..d62423a8c1d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.debug.js @@ -29,7 +29,7 @@ var template_default = _template("__tests__/template.marko", (input) => { }, "__tests__/template.marko_0/onClick", $scope0_id) }, _content_resume("__tests__/template.marko_1*content", () => { const $scope1_id = _scope_id(); _scope_reason(); - _html(`${_escape(count)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(count) || ""}${_el_resume($scope1_id, "#text/0")}`); _subscribe($count__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:2")); _resume_branch($scope1_id); }, $scope0_id)); diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.js index f0fedc65a00..b9148709c02 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/__snapshots__/html.bundle.js @@ -28,7 +28,7 @@ var template_default = _template("a", (input) => { }, "a0", $scope0_id) }, _content_resume("a1", () => { const $scope1_id = _scope_id(); _scope_reason(); - _html(`${_escape(count)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(count) || ""}${_el_resume($scope1_id, "a")}`); _subscribe($count__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id)); diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.debug.js index b8b152c1b7e..078072326ab 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.debug.js @@ -7,31 +7,31 @@ var template_default = _template("__tests__/template.marko", (input) => { _html(`${_el_resume($scope0_id, "#button/0")}

1 * ${_escape(n)}${_el_resume($scope0_id, "#text/1")} = `); _await($scope0_id, "#text/2", multiply(1, n), (result) => { const $scope1_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(result) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, {}, "__tests__/template.marko", "6:16"); }); _html(`

2 * ${_escape(n)}${_el_resume($scope0_id, "#text/3")} = `); _await($scope0_id, "#text/4", multiply(2, n), (result) => { const $scope2_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope2_id, "#text/0")}`); + _html(`${_escape(result) || ""}${_el_resume($scope2_id, "#text/0")}`); writeScope($scope2_id, {}, "__tests__/template.marko", "7:16"); }); _html(`

3 * ${_escape(n)}${_el_resume($scope0_id, "#text/5")} = `); _await($scope0_id, "#text/6", multiply(3, n), (result) => { const $scope3_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope3_id, "#text/0")}`); + _html(`${_escape(result) || ""}${_el_resume($scope3_id, "#text/0")}`); writeScope($scope3_id, {}, "__tests__/template.marko", "8:16"); }); _html(`

4 * ${_escape(n)}${_el_resume($scope0_id, "#text/7")} = `); _await($scope0_id, "#text/8", multiply(4, n), (result) => { const $scope4_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope4_id, "#text/0")}`); + _html(`${_escape(result) || ""}${_el_resume($scope4_id, "#text/0")}`); writeScope($scope4_id, {}, "__tests__/template.marko", "9:16"); }); _html(`

5 * ${_escape(n)}${_el_resume($scope0_id, "#text/9")} = `); _await($scope0_id, "#text/10", multiply(5, n), (result) => { const $scope5_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope5_id, "#text/0")}`); + _html(`${_escape(result) || ""}${_el_resume($scope5_id, "#text/0")}`); writeScope($scope5_id, {}, "__tests__/template.marko", "10:16"); }); _html("

"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.js index ae83a8bad8e..ff60062ee11 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/html.bundle.js @@ -7,31 +7,31 @@ var template_default = _template("a", (input) => { _html(`${_el_resume($scope0_id, "a")}

1 * ${_escape(n)}${_el_resume($scope0_id, "b")} = `); _await($scope0_id, "c", multiply(1, n), (result) => { const $scope1_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(result) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, {}); }); _html(`

2 * ${_escape(n)}${_el_resume($scope0_id, "d")} = `); _await($scope0_id, "e", multiply(2, n), (result) => { const $scope2_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope2_id, "a")}`); + _html(`${_escape(result) || ""}${_el_resume($scope2_id, "a")}`); writeScope($scope2_id, {}); }); _html(`

3 * ${_escape(n)}${_el_resume($scope0_id, "f")} = `); _await($scope0_id, "g", multiply(3, n), (result) => { const $scope3_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope3_id, "a")}`); + _html(`${_escape(result) || ""}${_el_resume($scope3_id, "a")}`); writeScope($scope3_id, {}); }); _html(`

4 * ${_escape(n)}${_el_resume($scope0_id, "h")} = `); _await($scope0_id, "i", multiply(4, n), (result) => { const $scope4_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope4_id, "a")}`); + _html(`${_escape(result) || ""}${_el_resume($scope4_id, "a")}`); writeScope($scope4_id, {}); }); _html(`

5 * ${_escape(n)}${_el_resume($scope0_id, "j")} = `); _await($scope0_id, "k", multiply(5, n), (result) => { const $scope5_id = _scope_id(); - _html(`${_escape(result)}${_el_resume($scope5_id, "a")}`); + _html(`${_escape(result) || ""}${_el_resume($scope5_id, "a")}`); writeScope($scope5_id, {}); }); _html("

"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.debug.js index 050bb348c88..222b7e4ff62 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.debug.js @@ -10,7 +10,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); _await($scope1_id, "#text/0", resolveAfter(clickCount), (value) => { const $scope3_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope3_id, "#text/0")}`); + _html(`${_escape(value) || ""}${_el_resume($scope3_id, "#text/0")}`); writeScope($scope3_id, {}, "__tests__/template.marko", "7:4"); }); _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "6:2")); diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.js index 49b381320e0..a80a2fd9dd0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/html.bundle.js @@ -10,7 +10,7 @@ var template_default = _template("a", (input) => { _scope_reason(); _await($scope1_id, "a", resolveAfter(clickCount), (value) => { const $scope3_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope3_id, "a")}`); + _html(`${_escape(value) || ""}${_el_resume($scope3_id, "a")}`); writeScope($scope3_id, {}); }); _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.debug.js index 950b5b226f2..d183772bd9b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.debug.js @@ -23,7 +23,7 @@ var template_default = _template("__tests__/template.marko", (input) => { $item = attrTags($item, { content: _content("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(a)}${_el_resume($scope1_id, "#text/0")}:${_escape(v)}${_el_resume($scope1_id, "#text/1")}`); + _html(`${_escape(a) || ""}${_el_resume($scope1_id, "#text/0")}:${_escape(v)}${_el_resume($scope1_id, "#text/1")}`); writeScope($scope1_id, {}, "__tests__/template.marko", "3:8"); }, $scope0_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.js index 6f8b0a9041b..c1864626ebe 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.bundle.js @@ -23,7 +23,7 @@ var template_default = _template("a", (input) => { $item = attrTags($item, { content: _content("a0", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(a)}${_el_resume($scope1_id, "a")}:${_escape(v)}${_el_resume($scope1_id, "b")}`); + _html(`${_escape(a) || ""}${_el_resume($scope1_id, "a")}:${_escape(v)}${_el_resume($scope1_id, "b")}`); writeScope($scope1_id, {}); }, $scope0_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.debug.js index 3b5965b5e64..d0ec455120a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.debug.js @@ -68,7 +68,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content_resume("__tests__/template.marko_3*content", () => { _scope_reason(); const $scope3_id = _scope_id(); - _html(`${_escape(row)}${_el_resume($scope3_id, "#text/0")}`); + _html(`${_escape(row) || ""}${_el_resume($scope3_id, "#text/0")}`); writeScope($scope3_id, {}, "__tests__/template.marko", "16:18"); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.js index 75e2055123d..b4260813ae6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.bundle.js @@ -65,7 +65,7 @@ var template_default = _template("a", (input) => { content: _content_resume("a2", () => { _scope_reason(); const $scope3_id = _scope_id(); - _html(`${_escape(row)}${_el_resume($scope3_id, "a")}`); + _html(`${_escape(row) || ""}${_el_resume($scope3_id, "a")}`); writeScope($scope3_id, {}); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.debug.js index bbfd209ee09..7ed29211bc4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.debug.js @@ -23,7 +23,7 @@ var template_default = _template("__tests__/template.marko", (input) => { $item = attrTags($item, { content: _content("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(zzz)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(zzz) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, {}, "__tests__/template.marko", "3:5"); }, $scope0_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.js index e2396034735..d35719ce95d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-closure/__snapshots__/html.bundle.js @@ -23,7 +23,7 @@ var template_default = _template("a", (input) => { $item = attrTags($item, { content: _content("a0", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(zzz)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(zzz) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, {}); }, $scope0_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.debug.js index 31781d74b1a..e0d9c049be9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.debug.js @@ -27,7 +27,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content_resume("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape($foo)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape($foo) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, {}, "__tests__/template.marko", "4:6"); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.js index ab05c0d88c5..a7c9eaed66a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-event-handler-shadowed/__snapshots__/html.bundle.js @@ -27,7 +27,7 @@ var template_default = _template("a", (input) => { content: _content_resume("a1", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape($foo)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape($foo) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, {}); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.debug.js index 71213c8f032..62576955d82 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.debug.js @@ -25,7 +25,7 @@ var template_default = _template("__tests__/template.marko", (input) => { $item = attrTags($item, { content: _content("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(item * mult)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(item * mult) || ""}${_el_resume($scope1_id, "#text/0")}`); _subscribe($mult__closures, writeScope($scope1_id, { item, _: _scope_with_id($scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.js index f0b6719e93d..faf2dfac00e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-for-loop-param-intersection-closure/__snapshots__/html.bundle.js @@ -25,7 +25,7 @@ var template_default = _template("a", (input) => { $item = attrTags($item, { content: _content("a0", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(item * mult)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(item * mult) || ""}${_el_resume($scope1_id, "a")}`); _subscribe($mult__closures, writeScope($scope1_id, { f: item, _: _scope_with_id($scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.debug.js index ef3963f82ea..3c0fed66835 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.debug.js @@ -4,7 +4,7 @@ var child_default = _template("__tests__/tags/child/index.marko", (input) => { const $scope0_id = _scope_id(); _for_of(input.scope, (s) => { const $scope1_id = _scope_id(); - _html(`${_escape(s.a)}${_el_resume($scope1_id, "#text/0", $sg__input_scope)}`); + _html(`${_escape(s.a) || _sep($sg__input_scope)}${_el_resume($scope1_id, "#text/0", $sg__input_scope)}`); $si__input_scope && writeScope($scope1_id, {}, "__tests__/tags/child/index.marko", "1:2"); }, 0, $scope0_id, "#text/0", $sg__input_scope, $sg__input_scope, $sg__input_scope, 0, 1); $si__input_scope && writeScope($scope0_id, {}, "__tests__/tags/child/index.marko", 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.js index a8c56109e9c..dc13909c347 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/at-tags-name-shadows-generated-uid/__snapshots__/html.bundle.js @@ -4,7 +4,7 @@ var child_default = _template("b", (input) => { const $scope0_id = _scope_id(); _for_of(input.scope, (s) => { const $scope1_id = _scope_id(); - _html(`${_escape(s.a)}${_el_resume($scope1_id, "a", $sg__input_scope)}`); + _html(`${_escape(s.a) || _sep($sg__input_scope)}${_el_resume($scope1_id, "a", $sg__input_scope)}`); $si__input_scope && writeScope($scope1_id, {}); }, 0, $scope0_id, "a", $sg__input_scope, $sg__input_scope, $sg__input_scope, 0, 1); $si__input_scope && writeScope($scope0_id, {}); diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.debug.js index 53b12d2cd19..29b5aaece02 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.debug.js @@ -19,7 +19,7 @@ var template_default = _template("__tests__/template.marko", (input) => { $item = attrTags($item, { content: _content("__tests__/template.marko_4*content", () => { _scope_reason(); const $scope4_id = _scope_id(); - _html(`${_escape(item.text)}${_el_resume($scope4_id, "#text/0")}`); + _html(`${_escape(item.text) || ""}${_el_resume($scope4_id, "#text/0")}`); writeScope($scope4_id, {}, "__tests__/template.marko", "11:14"); }, $scope2_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.js index 75fa62c7da6..9c5f88b800b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-tag-local-member-expression-closure/__snapshots__/html.bundle.js @@ -18,7 +18,7 @@ var template_default = _template("a", (input) => { $item = attrTags($item, { content: _content("a1", () => { _scope_reason(); const $scope4_id = _scope_id(); - _html(`${_escape(item.text)}${_el_resume($scope4_id, "a")}`); + _html(`${_escape(item.text) || ""}${_el_resume($scope4_id, "a")}`); writeScope($scope4_id, {}); }, $scope2_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.debug.js index 6e466f68857..2ff3d89d5e6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.debug.js @@ -14,7 +14,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _await($scope2_id, "#text/0", resolveAfter(0, 1), () => { const $scope3_id = _scope_id(); _script($scope3_id, "__tests__/template.marko_3_show#2/pending"); - _html(`${_escape(show)}${_el_resume($scope3_id, "#text/0")}`); + _html(`${_escape(show) || ""}${_el_resume($scope3_id, "#text/0")}`); _script($scope3_id, "__tests__/template.marko_3"); writeScope($scope3_id, { _: _scope_with_id($scope2_id) }, "__tests__/template.marko", "9:5"); _resume_branch($scope3_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.js index 6c2c58afbec..074e6522ca6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/await-cleanup/__snapshots__/html.bundle.js @@ -14,7 +14,7 @@ var template_default = _template("a", (input) => { _await($scope2_id, "a", resolveAfter(0, 1), () => { const $scope3_id = _scope_id(); _script($scope3_id, "a0"); - _html(`${_escape(show)}${_el_resume($scope3_id, "a")}`); + _html(`${_escape(show) || ""}${_el_resume($scope3_id, "a")}`); _script($scope3_id, "a1"); writeScope($scope3_id, { _: _scope_with_id($scope2_id) }); _resume_branch($scope3_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.debug.js index b6f4533dc37..5e0b11eee11 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.debug.js @@ -10,7 +10,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _await($scope1_id, "#text/0", resolveAfter(0, 4), () => { const $scope2_id = _scope_id(); _script($scope2_id, "__tests__/template.marko_2_value#1/pending"); - _html(`${_escape(value)}${_el_resume($scope2_id, "#text/0")}`); + _html(`${_escape(value) || ""}${_el_resume($scope2_id, "#text/0")}`); _script($scope2_id, "__tests__/template.marko_2_value#1"); writeScope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "6:3"); _resume_branch($scope2_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.js index 5bcf37250be..b18cfde64f7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/await-closure-function/__snapshots__/html.bundle.js @@ -10,7 +10,7 @@ var template_default = _template("a", (input) => { _await($scope1_id, "a", resolveAfter(0, 4), () => { const $scope2_id = _scope_id(); _script($scope2_id, "a0"); - _html(`${_escape(value)}${_el_resume($scope2_id, "a")}`); + _html(`${_escape(value) || ""}${_el_resume($scope2_id, "a")}`); _script($scope2_id, "a1"); writeScope($scope2_id, { _: _scope_with_id($scope1_id) }); _resume_branch($scope2_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.debug.js index a7707fb4078..00754eaec56 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.debug.js @@ -8,7 +8,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _html("
  • "); _await($scope1_id, "#text/0", resolveAfter(item.label, 1), (v) => { const $scope2_id = _scope_id(); - _html(`${_escape(v)}${_el_resume($scope2_id, "#text/0", $sg__input_items)}`); + _html(`${_escape(v) || _sep($sg__input_items)}${_el_resume($scope2_id, "#text/0", $sg__input_items)}`); $si__input_items && writeScope($scope2_id, {}, "__tests__/template.marko", "6:8"); }, $sg__input_items); _html("
  • "); diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.js index 3b83070fe38..f7d6543145f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/await-in-for/__snapshots__/html.bundle.js @@ -8,7 +8,7 @@ var template_default = _template("a", (input) => { _html("
  • "); _await($scope1_id, "a", resolveAfter(item.label, 1), (v) => { const $scope2_id = _scope_id(); - _html(`${_escape(v)}${_el_resume($scope2_id, "a", $sg__input_items)}`); + _html(`${_escape(v) || _sep($sg__input_items)}${_el_resume($scope2_id, "a", $sg__input_items)}`); $si__input_items && writeScope($scope2_id, {}); }, $sg__input_items); _html("
  • "); diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.debug.js index e621b6bdcb3..10e357c2b90 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.debug.js @@ -23,7 +23,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(clickCount)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(clickCount) || ""}${_el_resume($scope1_id, "#text/0")}`); _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:2")); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.js index 86163004745..545d57a1e50 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.bundle.js @@ -23,7 +23,7 @@ var template_default = _template("a", (input) => { content: _content("a1", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(clickCount)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(clickCount) || ""}${_el_resume($scope1_id, "a")}`); _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.debug.js index 00fe1888879..788e49a5ef9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.debug.js @@ -8,7 +8,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _if(() => { if (show) { const $scope1_id = _scope_id(); - _html(`${_escape(message.text)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(message.text) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, {}, "__tests__/template.marko", "8:2"); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.js index dc1ea1f96f0..86b949d6773 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-execution-order/__snapshots__/html.bundle.js @@ -7,7 +7,7 @@ var template_default = _template("a", (input) => { _if(() => { { const $scope1_id = _scope_id(); - _html(`${_escape(message.text)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(message.text) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, {}); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.debug.js index 9acf2834fc5..9d3bb7fde60 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.debug.js @@ -7,7 +7,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _html("
    "); _for_of(items, (item) => { const $scope1_id = _scope_id(); - _html(`${_escape(item)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(item) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, {}, "__tests__/template.marko", "5:4"); }, 0, $scope0_id, "#text/0", 1, 1, 1, 0, 1); _html(`${_el_resume($scope0_id, "#button/1")}${_el_resume($scope0_id, "#button/2")}
    `); diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.js index 147747c6938..d899a0c43fa 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.bundle.js @@ -7,7 +7,7 @@ var template_default = _template("a", (input) => { _html("
    "); _for_of(items, (item) => { const $scope1_id = _scope_id(); - _html(`${_escape(item)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(item) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, {}); }, 0, $scope0_id, "a", 1, 1, 1, 0, 1); _html(`${_el_resume($scope0_id, "b")}${_el_resume($scope0_id, "c")}
    `); diff --git a/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.debug.js index 1f5e87cedf1..4308a6487e8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.debug.js @@ -39,7 +39,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(x)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(x) || ""}${_el_resume($scope1_id, "#text/0")}`); _subscribe($x__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:2")); _resume_branch($scope1_id); }, $scope0_id) @@ -52,7 +52,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content("__tests__/template.marko_2*content", () => { _scope_reason(); const $scope2_id = _scope_id(); - _html(`${_escape(x)}${_el_resume($scope2_id, "#text/0")}`); + _html(`${_escape(x) || ""}${_el_resume($scope2_id, "#text/0")}`); _subscribe($x__closures, writeScope($scope2_id, { _: _scope_with_id($scope0_id), "ClosureSignalIndex:x": 1 diff --git a/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.js index 17939d90640..7fa7588829a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/bind-to-input/__snapshots__/html.bundle.js @@ -34,7 +34,7 @@ var template_default = _template("a", (input) => { content: _content("a1", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(x)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(x) || ""}${_el_resume($scope1_id, "a")}`); _subscribe($x__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id) @@ -47,7 +47,7 @@ var template_default = _template("a", (input) => { content: _content("a2", () => { _scope_reason(); const $scope2_id = _scope_id(); - _html(`${_escape(x)}${_el_resume($scope2_id, "a")}`); + _html(`${_escape(x) || ""}${_el_resume($scope2_id, "a")}`); _subscribe($x__closures, writeScope($scope2_id, { _: _scope_with_id($scope0_id), Cd: 1 diff --git a/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.debug.js index d0c8e0a5721..4e2fefb2af1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.debug.js @@ -24,7 +24,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(clickCount)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(clickCount) || ""}${_el_resume($scope1_id, "#text/0")}`); _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:2")); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.js index 49f3d4a57d8..8b45aba6790 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/body-content/__snapshots__/html.bundle.js @@ -24,7 +24,7 @@ var template_default = _template("a", (input) => { content: _content("a1", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(clickCount)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(clickCount) || ""}${_el_resume($scope1_id, "a")}`); _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.debug.js index 54f9ccd811a..c48b34e3dfd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.debug.js @@ -13,9 +13,9 @@ var template_default = _template("__tests__/template.marko", (input) => { }, 0); _html("c"); }, $scope0_id), { catch: attrTag({ content: _content_resume("__tests__/template.marko_2*content", (error) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__error_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(error.message)}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(error.message) || _sep($sg__error_message)}${_el_resume($scope2_id, "#text/0", $sg__error_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}, "__tests__/template.marko", "8:4"); }, $scope0_id) }) }); _html("d"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.js index 13c3e9f64e3..97af663ac5b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/html.bundle.js @@ -13,9 +13,9 @@ var template_default = _template("a", (input) => { }, 0); _html("c"); }, $scope0_id), { catch: attrTag({ content: _content_resume("a0", (error) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__error_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(error.message)}${_el_resume($scope2_id, "a", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(error.message) || _sep($sg__error_message)}${_el_resume($scope2_id, "a", $sg__error_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}); }, $scope0_id) }) }); _html("d"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.debug.js index ca84fa2a933..bd7bfc83c7a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.debug.js @@ -10,9 +10,9 @@ var template_default = _template("__tests__/template.marko", (input) => { throw new Error("ERROR!"); })())}`); }, $scope0_id), { catch: attrTag({ content: _content_resume("__tests__/template.marko_2*content", (error) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__error_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(error.message)}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(error.message) || _sep($sg__error_message)}${_el_resume($scope2_id, "#text/0", $sg__error_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}, "__tests__/template.marko", "4:4"); }, $scope0_id) }) }); _html("d"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.js index d1faea56b1e..cf328705331 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-throw-sync/__snapshots__/html.bundle.js @@ -10,9 +10,9 @@ var template_default = _template("a", (input) => { throw new Error("ERROR!"); })())}`); }, $scope0_id), { catch: attrTag({ content: _content_resume("a0", (error) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__error_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(error.message)}${_el_resume($scope2_id, "a", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(error.message) || _sep($sg__error_message)}${_el_resume($scope2_id, "a", $sg__error_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}); }, $scope0_id) }) }); _html("d"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.debug.js index a3ce9acd2c2..f5df77c8ca7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.debug.js @@ -32,7 +32,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content_resume("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(count)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(count) || ""}${_el_resume($scope1_id, "#text/0")}`); _subscribe($count__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4")); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.js index 3e634ac54f6..2d1c6f2d722 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/conditional-dynamic-tag-in-loop-closure/__snapshots__/html.bundle.js @@ -32,7 +32,7 @@ var template_default = _template("a", (input) => { content: _content_resume("a1", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(count)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(count) || ""}${_el_resume($scope1_id, "a")}`); _subscribe($count__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..b0e090abec0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,17 @@ +// template.marko +const $template = ""; +const $walks = " b%b"; +const $value = /*@__PURE__*/ _let("value/2", ($scope) => { + _attr_input_value($scope, "#input/0", $scope.value, $valueChange($scope)); + _text($scope["#text/1"], $scope.value); +}); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _attr_input_value_script($scope, "#input/0")); +function $setup($scope) { + $value($scope, undefined); + $setup__script($scope); +} +const $valueChange = ($scope) => (_new_value) => { + $value($scope, _new_value); +}; +_resume("__tests__/template.marko_0/valueChange", $valueChange); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..caf56855143 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/dom.bundle.js @@ -0,0 +1,10 @@ +// template.marko +const $value = /*@__PURE__*/ _let(2, ($scope) => { + _attr_input_value($scope, "a", $scope.c, $valueChange($scope)); + _text($scope.b, $scope.c); +}); +const $setup__script = _script("a1", ($scope) => _attr_input_value_script($scope, "a")); +const $valueChange = ($scope) => (_new_value) => { + $value($scope, _new_value); +}; +_resume("a0", $valueChange); diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..6cfb6c4fe6c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/html.bundle.debug.js @@ -0,0 +1,12 @@ +// template.marko +var template_default = _template("__tests__/template.marko", (input) => { + _scope_reason(); + const $scope0_id = _scope_id(); + let value = undefined; + _html(` { + value = _new_value; + }, "__tests__/template.marko_0/valueChange", $scope0_id))}>${_el_resume($scope0_id, "#input/0")}${_escape(value) || ""}${_el_resume($scope0_id, "#text/1")}`); + _script($scope0_id, "__tests__/template.marko_0"); + writeScope($scope0_id, {}, "__tests__/template.marko", 0, { "ControlledHandler:#input/0": ["valueChange"] }); + _resume_branch($scope0_id); +}, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..617e8d8057a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/html.bundle.js @@ -0,0 +1,12 @@ +// template.marko +var template_default = _template("a", (input) => { + _scope_reason(); + const $scope0_id = _scope_id(); + let value = void 0; + _html(` { + value = _new_value; + }, "a0", $scope0_id))}>${_el_resume($scope0_id, "a")}${_escape(value) || ""}${_el_resume($scope0_id, "b")}`); + _script($scope0_id, "a1"); + writeScope($scope0_id, {}); + _resume_branch($scope0_id); +}, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/render.debug.md new file mode 100644 index 00000000000..68cbd88190b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/render.debug.md @@ -0,0 +1,58 @@ +# Render +```html + +``` + +# Update +```js +const input = document.querySelector("input"); +const window = input.ownerDocument.defaultView; +input.value = value; +input.dispatchEvent(new window.Event("input", { bubbles: true })); +``` +```html + +w +``` +## Change +``` +UPDATE: ::text "" => "w" +``` + +# Update +```js +const input = document.querySelector("input"); +const window = input.ownerDocument.defaultView; +input.value = value; +input.dispatchEvent(new window.Event("input", { bubbles: true })); +``` +```html + +wor +``` +## Change +``` +UPDATE: ::text "w" => "wor" +``` + +# Update +```js +const input = document.querySelector("input"); +const window = input.ownerDocument.defaultView; +input.value = value; +input.dispatchEvent(new window.Event("input", { bubbles: true })); +``` +```html + +world +``` +## Change +``` +UPDATE: ::text "wor" => "world" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/render.md new file mode 100644 index 00000000000..68cbd88190b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/render.md @@ -0,0 +1,58 @@ +# Render +```html + +``` + +# Update +```js +const input = document.querySelector("input"); +const window = input.ownerDocument.defaultView; +input.value = value; +input.dispatchEvent(new window.Event("input", { bubbles: true })); +``` +```html + +w +``` +## Change +``` +UPDATE: ::text "" => "w" +``` + +# Update +```js +const input = document.querySelector("input"); +const window = input.ownerDocument.defaultView; +input.value = value; +input.dispatchEvent(new window.Event("input", { bubbles: true })); +``` +```html + +wor +``` +## Change +``` +UPDATE: ::text "w" => "wor" +``` + +# Update +```js +const input = document.querySelector("input"); +const window = input.ownerDocument.defaultView; +input.value = value; +input.dispatchEvent(new window.Event("input", { bubbles: true })); +``` +```html + +world +``` +## Change +``` +UPDATE: ::text "wor" => "world" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..cfdc4835c3a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/writes.debug.html @@ -0,0 +1,13 @@ + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/writes.html new file mode 100644 index 00000000000..92ebe604334 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/__snapshots__/writes.html @@ -0,0 +1,9 @@ + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/sizes.json new file mode 100644 index 00000000000..bee99947e0f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/sizes.json @@ -0,0 +1,12 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 3623, + "brotli": 1748 + } + }, + "html": { + "min": 353, + "brotli": 252 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/template.marko b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/template.marko new file mode 100644 index 00000000000..6c8fbfa89d0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/template.marko @@ -0,0 +1,3 @@ +let/value +input value:=value +-- ${value} diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/test.ts b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/test.ts new file mode 100644 index 00000000000..05788032592 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-input-value-empty/test.ts @@ -0,0 +1,14 @@ +import type { TestConfig } from "../../main.test"; + +function type(value: string) { + return (document: Document) => { + const input = document.querySelector("input")!; + const window = input.ownerDocument.defaultView!; + input.value = value; + input.dispatchEvent(new window.Event("input", { bubbles: true })); + }; +} + +export const config: TestConfig = { + steps: [{}, type("w"), type("wor"), type("world")], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.debug.js index 90d5e0cfe37..45e7482bed7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.debug.js @@ -4,7 +4,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); const Foo = { content: _content("__tests__/template.marko_1*content", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(), $sg__input_bar = _serialize_guard($scope1_reason, 1), $si__input_bar = _serialize_if($scope1_reason, 1); + const $scope1_reason = _scope_reason(), $sg__input_bar = _serialize_guard($scope1_reason, 1), $sg__input_message = _serialize_guard($scope1_reason, 2), $si__input_bar = _serialize_if($scope1_reason, 1); _if(() => { if (input.bar) { const $scope2_id = _scope_id(); @@ -21,7 +21,7 @@ var template_default = _template("__tests__/template.marko", (input) => { return 0; } else { const $scope3_id = _scope_id(); - _html(`${_escape(JSON.stringify(input.message))}${_el_resume($scope3_id, "#text/0", _serialize_guard($scope1_reason, 2))}`); + _html(`${_escape(JSON.stringify(input.message)) || _sep($sg__input_message)}${_el_resume($scope3_id, "#text/0", $sg__input_message)}`); _serialize_if($scope1_reason, 0) && writeScope($scope3_id, { _: _serialize_if($scope1_reason, 2) && _scope_with_id($scope1_id) }, "__tests__/template.marko", "4:3"); return 1; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.js index 25bee09190d..823ea09d3e4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-known/__snapshots__/html.bundle.js @@ -3,7 +3,7 @@ var template_default = _template("a", (input) => { _scope_reason(); const Foo = { content: _content("a0", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(), $sg__input_bar = _serialize_guard($scope1_reason, 1), $si__input_bar = _serialize_if($scope1_reason, 1); + const $scope1_reason = _scope_reason(), $sg__input_bar = _serialize_guard($scope1_reason, 1), $sg__input_message = _serialize_guard($scope1_reason, 2), $si__input_bar = _serialize_if($scope1_reason, 1); _if(() => { if (input.bar) { const $scope2_id = _scope_id(); @@ -20,7 +20,7 @@ var template_default = _template("a", (input) => { return 0; } else { const $scope3_id = _scope_id(); - _html(`${_escape(JSON.stringify(input.message))}${_el_resume($scope3_id, "a", _serialize_guard($scope1_reason, 2))}`); + _html(`${_escape(JSON.stringify(input.message)) || _sep($sg__input_message)}${_el_resume($scope3_id, "a", $sg__input_message)}`); _serialize_if($scope1_reason, 0) && writeScope($scope3_id, { _: _serialize_if($scope1_reason, 2) && _scope_with_id($scope1_id) }); return 1; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.debug.js index 14cedb290f8..0837d9c94ee 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.debug.js @@ -4,7 +4,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); const Foo = { content: _content_resume("__tests__/template.marko_1*content", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(), $sg__input_bar = _serialize_guard($scope1_reason, 1), $si__input_bar = _serialize_if($scope1_reason, 1); + const $scope1_reason = _scope_reason(), $sg__input_message = _serialize_guard($scope1_reason, 2), $sg__input_bar = _serialize_guard($scope1_reason, 1), $si__input_bar = _serialize_if($scope1_reason, 1); _if(() => { if (input.bar) { const $scope2_id = _scope_id(); @@ -13,7 +13,7 @@ var template_default = _template("__tests__/template.marko", (input) => { return 0; } else { const $scope3_id = _scope_id(); - _html(`${_escape(JSON.stringify(input.message))}${_el_resume($scope3_id, "#text/0", _serialize_guard($scope1_reason, 2))}`); + _html(`${_escape(JSON.stringify(input.message)) || _sep($sg__input_message)}${_el_resume($scope3_id, "#text/0", $sg__input_message)}`); _serialize_if($scope1_reason, 0) && writeScope($scope3_id, { _: _serialize_if($scope1_reason, 2) && _scope_with_id($scope1_id) }, "__tests__/template.marko", "4:3"); return 1; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.js index 6ef882d9448..e4acbeeb803 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/define-tag-recursive-unknown/__snapshots__/html.bundle.js @@ -4,7 +4,7 @@ var template_default = _template("a", (input) => { const $scope0_id = _scope_id(); const Foo = { content: _content_resume("a0", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(), $sg__input_bar = _serialize_guard($scope1_reason, 1), $si__input_bar = _serialize_if($scope1_reason, 1); + const $scope1_reason = _scope_reason(), $sg__input_message = _serialize_guard($scope1_reason, 2), $sg__input_bar = _serialize_guard($scope1_reason, 1), $si__input_bar = _serialize_if($scope1_reason, 1); _if(() => { if (input.bar) { const $scope2_id = _scope_id(); @@ -13,7 +13,7 @@ var template_default = _template("a", (input) => { return 0; } else { const $scope3_id = _scope_id(); - _html(`${_escape(JSON.stringify(input.message))}${_el_resume($scope3_id, "a", _serialize_guard($scope1_reason, 2))}`); + _html(`${_escape(JSON.stringify(input.message)) || _sep($sg__input_message)}${_el_resume($scope3_id, "a", $sg__input_message)}`); _serialize_if($scope1_reason, 0) && writeScope($scope3_id, { _: _serialize_if($scope1_reason, 2) && _scope_with_id($scope1_id) }); return 1; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.debug.js index b0fe2c7b80f..ca762d1a4e7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.debug.js @@ -27,7 +27,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content_resume("__tests__/template.marko_1*content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(value) || ""}${_el_resume($scope1_id, "#text/0")}`); _subscribe($value__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:1")); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.js index 9acdf5ef0c9..b4b1d700e95 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-input-with-assignment/__snapshots__/html.bundle.js @@ -24,7 +24,7 @@ var template_default = _template("a", (input) => { content: _content_resume("a1", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(value) || ""}${_el_resume($scope1_id, "a")}`); _subscribe($value__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.debug.js index 01e20bb221d..e041aa43b81 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.debug.js @@ -8,7 +8,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const MyThing = { content: _content_resume("__tests__/template.marko_1*content", () => { const $scope1_id = _scope_id(); _scope_reason(); - _html(`${_escape(count)}${_el_resume($scope1_id, "#text/0")} ${_escape(sideEffect++)}`); + _html(`${_escape(count) || ""}${_el_resume($scope1_id, "#text/0")} ${_escape(sideEffect++)}`); _subscribe($count__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "5:1")); _resume_branch($scope1_id); }, $scope0_id) }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.js index 5cefb3d0ac8..687a6cf89e3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-content-attr/__snapshots__/html.bundle.js @@ -8,7 +8,7 @@ var template_default = _template("a", (input) => { const MyThing = { content: _content_resume("a0", () => { const $scope1_id = _scope_id(); _scope_reason(); - _html(`${_escape(count)}${_el_resume($scope1_id, "a")} ${_escape(sideEffect++)}`); + _html(`${_escape(count) || ""}${_el_resume($scope1_id, "a")} ${_escape(sideEffect++)}`); _subscribe($count__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id) }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/error-for-by-static/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/error-for-by-static/__snapshots__/html.bundle.debug.js index 2a21f3ac518..00b0edc9398 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/error-for-by-static/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/error-for-by-static/__snapshots__/html.bundle.debug.js @@ -4,7 +4,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); _for_of(input.items, (item) => { const $scope1_id = _scope_id(); - _html(`${_escape(item.id)}${_el_resume($scope1_id, "#text/0", $sg__input_items)}`); + _html(`${_escape(item.id) || _sep($sg__input_items)}${_el_resume($scope1_id, "#text/0", $sg__input_items)}`); $si__input_items && writeScope($scope1_id, {}, "__tests__/template.marko", "1:2"); }, (item) => item, $scope0_id, "#text/0", $sg__input_items, $sg__input_items, $sg__input_items, 0, 1); $si__input_items && writeScope($scope0_id, {}, "__tests__/template.marko", 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.debug.js index ca7c170790e..6810022d5b3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.debug.js @@ -28,31 +28,31 @@ var template_default = _template("__tests__/template.marko", (input) => { _html("
    "); _for_of(items, ({ text }) => { const $scope1_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(text) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, {}, "__tests__/template.marko", "17:6"); }, "id", $scope0_id, "#div/0", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope2_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope2_id, "#text/0")}`); + _html(`${_escape(text) || ""}${_el_resume($scope2_id, "#text/0")}`); writeScope($scope2_id, {}, "__tests__/template.marko", "21:6"); }, (item) => item.id, $scope0_id, "#div/1", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope3_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope3_id, "#text/0")}`); + _html(`${_escape(text) || ""}${_el_resume($scope3_id, "#text/0")}`); writeScope($scope3_id, {}, "__tests__/template.marko", "25:6"); }, getStringBy(), $scope0_id, "#div/2", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope4_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope4_id, "#text/0")}`); + _html(`${_escape(text) || ""}${_el_resume($scope4_id, "#text/0")}`); writeScope($scope4_id, {}, "__tests__/template.marko", "29:6"); }, getFunctionBy(), $scope0_id, "#div/3", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope5_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope5_id, "#text/0")}`); + _html(`${_escape(text) || ""}${_el_resume($scope5_id, "#text/0")}`); writeScope($scope5_id, {}, "__tests__/template.marko", "33:6"); }, getMissingBy(), $scope0_id, "#div/4", 1, 1, 1, "
    ", 1); _html(`${_el_resume($scope0_id, "#button/5")}
    `); diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.js index 92ff7a85b46..81536b296dc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-by/__snapshots__/html.bundle.js @@ -25,31 +25,31 @@ var template_default = _template("a", (input) => { _html("
    "); _for_of(items, ({ text }) => { const $scope1_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(text) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, {}); }, "id", $scope0_id, "a", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope2_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope2_id, "a")}`); + _html(`${_escape(text) || ""}${_el_resume($scope2_id, "a")}`); writeScope($scope2_id, {}); }, (item) => item.id, $scope0_id, "b", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope3_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope3_id, "a")}`); + _html(`${_escape(text) || ""}${_el_resume($scope3_id, "a")}`); writeScope($scope3_id, {}); }, getStringBy(), $scope0_id, "c", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope4_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope4_id, "a")}`); + _html(`${_escape(text) || ""}${_el_resume($scope4_id, "a")}`); writeScope($scope4_id, {}); }, getFunctionBy(), $scope0_id, "d", 1, 1, 1, "
    ", 1); _html("
    "); _for_of(items, ({ text }) => { const $scope5_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope5_id, "a")}`); + _html(`${_escape(text) || ""}${_el_resume($scope5_id, "a")}`); writeScope($scope5_id, {}); }, void 0, $scope0_id, "e", 1, 1, 1, "
    ", 1); _html(`${_el_resume($scope0_id, "f")}
    `); diff --git a/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.debug.js index 81774a25ab9..02880666024 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.debug.js @@ -19,11 +19,11 @@ var template_default = _template("__tests__/template.marko", (input) => { const $childScope = _peek_scope_id(); let divName = parent_el_default({}); _var($scope0_id, "#scopeOffset/1", $childScope, "__tests__/template.marko_0_divName#6/var"); - _html(`${_escape(divName)}${_el_resume($scope0_id, "#text/2")}`); + _html(`${_escape(divName) || ""}${_el_resume($scope0_id, "#text/2")}`); const $childScope2 = _peek_scope_id(); let spanName = parent_el_default({}); _var($scope0_id, "#scopeOffset/4", $childScope2, "__tests__/template.marko_0_spanName#7/var"); - _html(`${_escape(spanName)}${_el_resume($scope0_id, "#text/5")}`); + _html(`${_escape(spanName) || ""}${_el_resume($scope0_id, "#text/5")}`); writeScope($scope0_id, { "#childScope/0": _existing_scope($childScope), "#childScope/3": _existing_scope($childScope2) diff --git a/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.js index d11e0165719..fd434f22c36 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/html-comment-var/__snapshots__/html.bundle.js @@ -16,11 +16,11 @@ var template_default = _template("a", (input) => { const $childScope = _peek_scope_id(); let divName = parent_el_default({}); _var($scope0_id, "b", $childScope, "a0"); - _html(`${_escape(divName)}${_el_resume($scope0_id, "c")}`); + _html(`${_escape(divName) || ""}${_el_resume($scope0_id, "c")}`); const $childScope2 = _peek_scope_id(); let spanName = parent_el_default({}); _var($scope0_id, "e", $childScope2, "a1"); - _html(`${_escape(spanName)}${_el_resume($scope0_id, "f")}`); + _html(`${_escape(spanName) || ""}${_el_resume($scope0_id, "f")}`); writeScope($scope0_id, { a: _existing_scope($childScope), d: _existing_scope($childScope2) diff --git a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.debug.js index 41d480f673d..a57434e6c62 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.debug.js @@ -6,7 +6,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _if(() => { if (input.show) { const $scope1_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(value) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:2"); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.js index fbb84a9c1f7..3bb9fe0b89e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-active/__snapshots__/html.bundle.js @@ -6,7 +6,7 @@ var template_default = _template("a", (input) => { _if(() => { if (input.show) { const $scope1_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(value) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.debug.js index 41d480f673d..a57434e6c62 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.debug.js @@ -6,7 +6,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _if(() => { if (input.show) { const $scope1_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope1_id, "#text/0")}`); + _html(`${_escape(value) || ""}${_el_resume($scope1_id, "#text/0")}`); writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:2"); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.js index fbb84a9c1f7..3bb9fe0b89e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/inert-if-closure-update-inactive/__snapshots__/html.bundle.js @@ -6,7 +6,7 @@ var template_default = _template("a", (input) => { _if(() => { if (input.show) { const $scope1_id = _scope_id(); - _html(`${_escape(value)}${_el_resume($scope1_id, "a")}`); + _html(`${_escape(value) || ""}${_el_resume($scope1_id, "a")}`); writeScope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.debug.js index 853c44b5ef9..967d62b0d9f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.debug.js @@ -19,9 +19,9 @@ var template_default = _template("__tests__/template.marko", (input) => { child_default({ value: "Hi", content: _content("__tests__/template.marko_1*content", (x) => { - const $scope1_reason = _scope_reason(); + const $scope1_reason = _scope_reason(), $sg__x = _serialize_guard($scope1_reason, 0); const $scope1_id = _scope_id(); - _html(`${_escape(x)}${_el_resume($scope1_id, "#text/0", _serialize_guard($scope1_reason, 0))}`); + _html(`${_escape(x) || _sep($sg__x)}${_el_resume($scope1_id, "#text/0", $sg__x)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}, "__tests__/template.marko", "1:2"); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.js index 55d6d781df6..830fc658fd6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/inert-params-no-serialize/__snapshots__/html.bundle.js @@ -15,9 +15,9 @@ var template_default = _template("a", (input) => { child_default({ value: "Hi", content: _content("a0", (x) => { - const $scope1_reason = _scope_reason(); + const $scope1_reason = _scope_reason(), $sg__x = _serialize_guard($scope1_reason, 0); const $scope1_id = _scope_id(); - _html(`${_escape(x)}${_el_resume($scope1_id, "a", _serialize_guard($scope1_reason, 0))}`); + _html(`${_escape(x) || _sep($sg__x)}${_el_resume($scope1_id, "a", $sg__x)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}); }, _scope_id()) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.debug.js index cf2cb9d2912..430a90a9567 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.debug.js @@ -1,19 +1,19 @@ // template.marko var template_default = _template("__tests__/template.marko", (input) => { - const $scope0_reason = _scope_reason(), $sg__input_text = _serialize_guard($scope0_reason, 0), $si__input_text = _serialize_if($scope0_reason, 0); + const $scope0_reason = _scope_reason(), $sg__input_text2 = _serialize_guard($scope0_reason, 0), $si__input_text = _serialize_if($scope0_reason, 0); const $scope0_id = _scope_id(); const $input_text__closures = new Set(); const Child = { content: _content("__tests__/template.marko_1*content", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(); - _html(`${_escape(input.text)}${_el_resume($scope1_id, "#text/0", _serialize_guard($scope1_reason, 1))} and `); + const $scope1_reason = _scope_reason(), $sg__input_text = _serialize_guard($scope1_reason, 1); + _html(`${_escape(input.text) || _sep($sg__input_text)}${_el_resume($scope1_id, "#text/0", $sg__input_text)} and `); _dynamic_tag($scope1_id, "#text/1", input.content, {}, 0, 0, _serialize_guard($scope1_reason, 2)); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}, "__tests__/template.marko", "1:1"); }, $scope0_id) }; const { text } = input; _set_serialize_reason({ - 0: $sg__input_text, - 1: $sg__input_text + 0: $sg__input_text2, + 1: $sg__input_text2 }); const $childScope = _peek_scope_id(); Child.content({ @@ -21,7 +21,7 @@ var template_default = _template("__tests__/template.marko", (input) => { content: _content("__tests__/template.marko_2*content", () => { const $scope2_reason = _scope_reason(); const $scope2_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope2_id, "#text/0", $sg__input_text)}`); + _html(`${_escape(text) || _sep($sg__input_text2)}${_el_resume($scope2_id, "#text/0", $sg__input_text2)}`); $si__input_text && _subscribe($input_text__closures, writeScope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "7:1")); _resume_branch($scope2_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.js index e8e8fa7d848..f701d96a19b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/input-property-alias-closure/__snapshots__/html.bundle.js @@ -1,19 +1,19 @@ // template.marko var template_default = _template("a", (input) => { - const $scope0_reason = _scope_reason(), $sg__input_text = _serialize_guard($scope0_reason, 0), $si__input_text = _serialize_if($scope0_reason, 0); + const $scope0_reason = _scope_reason(), $sg__input_text2 = _serialize_guard($scope0_reason, 0), $si__input_text = _serialize_if($scope0_reason, 0); const $scope0_id = _scope_id(); const $input_text__closures = /* @__PURE__ */ new Set(); const Child = { content: _content("a0", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(); - _html(`${_escape(input.text)}${_el_resume($scope1_id, "a", _serialize_guard($scope1_reason, 1))} and `); + const $scope1_reason = _scope_reason(), $sg__input_text = _serialize_guard($scope1_reason, 1); + _html(`${_escape(input.text) || _sep($sg__input_text)}${_el_resume($scope1_id, "a", $sg__input_text)} and `); _dynamic_tag($scope1_id, "b", input.content, {}, 0, 0, _serialize_guard($scope1_reason, 2)); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}); }, $scope0_id) }; const { text } = input; _set_serialize_reason({ - 0: $sg__input_text, - 1: $sg__input_text + 0: $sg__input_text2, + 1: $sg__input_text2 }); const $childScope = _peek_scope_id(); Child.content({ @@ -21,7 +21,7 @@ var template_default = _template("a", (input) => { content: _content("a1", () => { _scope_reason(); const $scope2_id = _scope_id(); - _html(`${_escape(text)}${_el_resume($scope2_id, "a", $sg__input_text)}`); + _html(`${_escape(text) || _sep($sg__input_text2)}${_el_resume($scope2_id, "a", $sg__input_text2)}`); $si__input_text && _subscribe($input_text__closures, writeScope($scope2_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope2_id); }, $scope0_id) diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.debug.js index 715620f9d33..908057c9810 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.debug.js @@ -4,8 +4,8 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); const Foo = { content: _content("__tests__/template.marko_1*content", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(); - _html(`${_escape(input.foo || "fallback")}${_el_resume($scope1_id, "#text/0", _serialize_guard($scope1_reason, 0))}`); + const $scope1_reason = _scope_reason(), $sg__input_foo = _serialize_guard($scope1_reason, 0); + _html(`${_escape(input.foo || "fallback") || _sep($sg__input_foo)}${_el_resume($scope1_id, "#text/0", $sg__input_foo)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}, "__tests__/template.marko", "1:2"); }, $scope0_id) }; const Bar = { content: _content("__tests__/template.marko_2*content", (input) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.js index 30c360e6588..bccc4b0d2c0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/known-tag-spread-unused/__snapshots__/html.bundle.js @@ -4,8 +4,8 @@ var template_default = _template("a", (input) => { const $scope0_id = _scope_id(); const Foo = { content: _content("a0", (input) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(); - _html(`${_escape(input.foo || "fallback")}${_el_resume($scope1_id, "a", _serialize_guard($scope1_reason, 0))}`); + const $scope1_reason = _scope_reason(), $sg__input_foo = _serialize_guard($scope1_reason, 0); + _html(`${_escape(input.foo || "fallback") || _sep($sg__input_foo)}${_el_resume($scope1_id, "a", $sg__input_foo)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}); }, $scope0_id) }; ({ content: _content("a1", (input) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.debug.js index e01160b6f6b..9b2ba910eb9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.debug.js @@ -1,10 +1,10 @@ // template.marko var template_default = _template("__tests__/template.marko", (input) => { - const $scope0_reason = _scope_reason(); + const $scope0_reason = _scope_reason(), $sg__input_a = _serialize_guard($scope0_reason, 0); const $scope0_id = _scope_id(); const { a } = input; let b = a * 2; - _html(`${_el_resume($scope0_id, "#button/0")}${_escape(a)}${_el_resume($scope0_id, "#text/1", _serialize_guard($scope0_reason, 0))} ${_escape(b)}${_el_resume($scope0_id, "#text/2")}`); + _html(`${_el_resume($scope0_id, "#button/0")}${_escape(a) || _sep($sg__input_a)}${_el_resume($scope0_id, "#text/1", $sg__input_a)} ${_escape(b)}${_el_resume($scope0_id, "#text/2")}`); _script($scope0_id, "__tests__/template.marko_0"); writeScope($scope0_id, { b }, "__tests__/template.marko", 0, { b: "2:6" }); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.js index f3fc2f88b74..d94ad709f8d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/let-tag-derived/__snapshots__/html.bundle.js @@ -1,10 +1,10 @@ // template.marko var template_default = _template("a", (input) => { - const $scope0_reason = _scope_reason(); + const $sg__input_a = _serialize_guard(_scope_reason(), 0); const $scope0_id = _scope_id(); const { a } = input; let b = a * 2; - _html(`${_el_resume($scope0_id, "a")}${_escape(a)}${_el_resume($scope0_id, "b", _serialize_guard($scope0_reason, 0))} ${_escape(b)}${_el_resume($scope0_id, "c")}`); + _html(`${_el_resume($scope0_id, "a")}${_escape(a) || _sep($sg__input_a)}${_el_resume($scope0_id, "b", $sg__input_a)} ${_escape(b)}${_el_resume($scope0_id, "c")}`); _script($scope0_id, "a0"); writeScope($scope0_id, { g: b }); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.debug.js index e4d9662957d..6eea2e109b3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.debug.js @@ -6,7 +6,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const y = x + 1; const z = x + 2; const a = y + z; - _html(`${_el_resume($scope0_id, "#button/0")}${_escape(y)}${_el_resume($scope0_id, "#text/2")} ${_escape(z)}${_el_resume($scope0_id, "#text/3")} ${_escape(a)}${_el_resume($scope0_id, "#text/4")}`); + _html(`${_el_resume($scope0_id, "#button/0")}${_escape(y) || ""}${_el_resume($scope0_id, "#text/2")} ${_escape(z)}${_el_resume($scope0_id, "#text/3")} ${_escape(a)}${_el_resume($scope0_id, "#text/4")}`); _script($scope0_id, "__tests__/template.marko_0"); writeScope($scope0_id, { x }, "__tests__/template.marko", 0, { x: "1:6" }); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.js index 8948bc2ea7b..de1fadb6cf9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/let-tag-with-intersection/__snapshots__/html.bundle.js @@ -3,7 +3,7 @@ var template_default = _template("a", (input) => { _scope_reason(); const $scope0_id = _scope_id(); let x = 1; - _html(`${_el_resume($scope0_id, "a")}${_escape(2)}${_el_resume($scope0_id, "c")} ${_escape(3)}${_el_resume($scope0_id, "d")} ${_escape(5)}${_el_resume($scope0_id, "e")}`); + _html(`${_el_resume($scope0_id, "a")}${_escape(2) || ""}${_el_resume($scope0_id, "c")} ${_escape(3)}${_el_resume($scope0_id, "d")} ${_escape(5)}${_el_resume($scope0_id, "e")}`); _script($scope0_id, "a0"); writeScope($scope0_id, { f: x }); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.debug.js index 716e35d7b1d..d5505fcf153 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.debug.js @@ -4,7 +4,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); let x = 1; let y = 1; - _html(`${_el_resume($scope0_id, "#button/0")}${_escape(y)}${_el_resume($scope0_id, "#text/2")}`); + _html(`${_el_resume($scope0_id, "#button/0")}${_escape(y) || ""}${_el_resume($scope0_id, "#text/2")}`); _script($scope0_id, "__tests__/template.marko_0"); writeScope($scope0_id, { x, diff --git a/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.js index c45ca7aad63..95c9730e554 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/let-tag/__snapshots__/html.bundle.js @@ -4,7 +4,7 @@ var template_default = _template("a", (input) => { const $scope0_id = _scope_id(); let x = 1; let y = 1; - _html(`${_el_resume($scope0_id, "a")}${_escape(y)}${_el_resume($scope0_id, "c")}`); + _html(`${_el_resume($scope0_id, "a")}${_escape(y) || ""}${_el_resume($scope0_id, "c")}`); _script($scope0_id, "a0"); writeScope($scope0_id, { d: x, diff --git a/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.debug.js index 658e999babc..da750a4ca09 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.debug.js @@ -4,8 +4,8 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); const A = { content: _content("__tests__/template.marko_1*content", ({ value }) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(); - _html(`${_escape(value)}${_el_resume($scope1_id, "#text/0", _serialize_guard($scope1_reason, 0))}`); + const $scope1_reason = _scope_reason(), $sg__value = _serialize_guard($scope1_reason, 0); + _html(`${_escape(value) || _sep($sg__value)}${_el_resume($scope1_id, "#text/0", $sg__value)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}, "__tests__/template.marko", "1:1"); }, $scope0_id) }; const B = { content: _content("__tests__/template.marko_2*content", ({ value }) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.js index f3717766163..724bf59d7e7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/merged-define-tag-templates/__snapshots__/html.bundle.js @@ -4,8 +4,8 @@ var template_default = _template("a", (input) => { const $scope0_id = _scope_id(); const A = { content: _content("a0", ({ value }) => { const $scope1_id = _scope_id(); - const $scope1_reason = _scope_reason(); - _html(`${_escape(value)}${_el_resume($scope1_id, "a", _serialize_guard($scope1_reason, 0))}`); + const $scope1_reason = _scope_reason(), $sg__value = _serialize_guard($scope1_reason, 0); + _html(`${_escape(value) || _sep($sg__value)}${_el_resume($scope1_id, "a", $sg__value)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}); }, $scope0_id) }; const B = { content: _content("a1", ({ value }) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.debug.js index d75fb35ddf6..cbdee6cdf04 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.debug.js @@ -6,7 +6,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _html("
    "); _for_of(children, (child) => { const $scope1_id = _scope_id(); - _html(`${_escape(child.text)}${_el_resume($scope1_id, "#text/0", $sg__input_children)}`); + _html(`${_escape(child.text) || _sep($sg__input_children)}${_el_resume($scope1_id, "#text/0", $sg__input_children)}`); $si__input_children && writeScope($scope1_id, {}, "__tests__/template.marko", "3:4"); }, function(c) { return c.id; diff --git a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.js index 05b7419fbfc..3c2158ae7bc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.bundle.js @@ -6,7 +6,7 @@ var template_default = _template("a", (input) => { _html("
    "); _for_of(children, (child) => { const $scope1_id = _scope_id(); - _html(`${_escape(child.text)}${_el_resume($scope1_id, "a", $sg__input_children)}`); + _html(`${_escape(child.text) || _sep($sg__input_children)}${_el_resume($scope1_id, "a", $sg__input_children)}`); $si__input_children && writeScope($scope1_id, {}); }, function(c) { return c.id; diff --git a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.debug.js index bfafe93804c..bcd8fe1dd4d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.debug.js @@ -4,7 +4,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); _for_of(input.children, (child) => { const $scope1_id = _scope_id(); - _html(`${_escape(child.text)}${_el_resume($scope1_id, "#text/0", $sg__input_children)}`); + _html(`${_escape(child.text) || _sep($sg__input_children)}${_el_resume($scope1_id, "#text/0", $sg__input_children)}`); $si__input_children && writeScope($scope1_id, {}, "__tests__/template.marko", "1:2"); }, function(c) { return c.id; diff --git a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.js index a02a7a882ad..7bb45082c23 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.bundle.js @@ -4,7 +4,7 @@ var template_default = _template("a", (input) => { const $scope0_id = _scope_id(); _for_of(input.children, (child) => { const $scope1_id = _scope_id(); - _html(`${_escape(child.text)}${_el_resume($scope1_id, "a", $sg__input_children)}`); + _html(`${_escape(child.text) || _sep($sg__input_children)}${_el_resume($scope1_id, "a", $sg__input_children)}`); $si__input_children && writeScope($scope1_id, {}); }, function(c) { return c.id; diff --git a/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.debug.js index 24eff117e48..0488b63a914 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.debug.js @@ -20,9 +20,9 @@ var template_default = _template("__tests__/template.marko", (input) => { my_for_default({ to: 5, content: _content("__tests__/template.marko_1*content", (i) => { - const $scope1_reason = _scope_reason(); + const $scope1_reason = _scope_reason(), $sg__i = _serialize_guard($scope1_reason, 0); const $scope1_id = _scope_id(); - _html(`${_escape(i)}${_el_resume($scope1_id, "#text/0", _serialize_guard($scope1_reason, 0))}`); + _html(`${_escape(i) || _sep($sg__i)}${_el_resume($scope1_id, "#text/0", $sg__i)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}, "__tests__/template.marko", "1:2"); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.js index d05cf9c58a2..48d57681509 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/my-for-to/__snapshots__/html.bundle.js @@ -19,9 +19,9 @@ var template_default = _template("a", (input) => { my_for_default({ to: 5, content: _content("a0", (i) => { - const $scope1_reason = _scope_reason(); + const $scope1_reason = _scope_reason(), $sg__i = _serialize_guard($scope1_reason, 0); const $scope1_id = _scope_id(); - _html(`${_escape(i)}${_el_resume($scope1_id, "a", _serialize_guard($scope1_reason, 0))}`); + _html(`${_escape(i) || _sep($sg__i)}${_el_resume($scope1_id, "a", $sg__i)}`); _serialize_if($scope1_reason, 0) && writeScope($scope1_id, {}); }, _scope_id()) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.debug.js index 454c6df2085..351ed8d79f5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.debug.js @@ -21,7 +21,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _dynamic_tag($scope0_id, "#text/5", Parent, {}, _content_resume("__tests__/template.marko_1*content", () => { const $scope1_id = _scope_id(); const $scope1_reason = _scope_reason(); - _html(`${_unescaped(input.value)}${_el_resume($scope1_id, "#text/0", $sg__input_value)}`); + _html(`${_unescaped(input.value) || _sep($sg__input_value)}${_el_resume($scope1_id, "#text/0", $sg__input_value)}`); _subscribe($si__input_value && $input_value__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "12:3")); _resume_branch($scope1_id); }, $scope0_id)); diff --git a/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.js index d76213993cc..bdc587b7639 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/namespaced-tags/__snapshots__/html.bundle.js @@ -21,7 +21,7 @@ var template_default = _template("a", (input) => { _dynamic_tag($scope0_id, "f", Parent, {}, _content_resume("a2", () => { const $scope1_id = _scope_id(); _scope_reason(); - _html(`${_unescaped(input.value)}${_el_resume($scope1_id, "a", $sg__input_value)}`); + _html(`${_unescaped(input.value) || _sep($sg__input_value)}${_el_resume($scope1_id, "a", $sg__input_value)}`); _subscribe($si__input_value && $input_value__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id)); diff --git a/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.debug.js index ec592e58bce..df917379e36 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.debug.js @@ -22,7 +22,7 @@ var template_default = _template("__tests__/template.marko", (input) => { $item = attrTags($item, { content: _content_resume("__tests__/template.marko_3*content", () => { _scope_reason(); const $scope3_id = _scope_id(); - _html(`${_escape(i)}${_el_resume($scope3_id, "#text/0")}`); + _html(`${_escape(i) || ""}${_el_resume($scope3_id, "#text/0")}`); writeScope($scope3_id, {}, "__tests__/template.marko", "11:6"); }, $scope0_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.js index fa9d56c08ff..477b73e8012 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/native-tag-local-closures/__snapshots__/html.bundle.js @@ -22,7 +22,7 @@ var template_default = _template("a", (input) => { $item = attrTags($item, { content: _content_resume("a2", () => { _scope_reason(); const $scope3_id = _scope_id(); - _html(`${_escape(i)}${_el_resume($scope3_id, "a")}`); + _html(`${_escape(i) || ""}${_el_resume($scope3_id, "a")}`); writeScope($scope3_id, {}); }, $scope0_id) }); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.debug.js index c2004315ce9..fe28c6000dc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.debug.js @@ -3,7 +3,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); let b = ""; - _html(`
    s${_escape(b)}${_el_resume($scope0_id, "#text/0")}
    ${_escape(b)}${_el_resume($scope0_id, "#text/1")}
    ${_el_resume($scope0_id, "#button/2")}`); + _html(`
    s${_escape(b) || ""}${_el_resume($scope0_id, "#text/0")}
    ${_escape(b) || ""}${_el_resume($scope0_id, "#text/1")}
    ${_el_resume($scope0_id, "#button/2")}`); _script($scope0_id, "__tests__/template.marko_0"); writeScope($scope0_id, {}, "__tests__/template.marko", 0); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.js index 4bd90115627..b68866084e1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-after-node/__snapshots__/html.bundle.js @@ -3,7 +3,7 @@ var template_default = _template("a", (input) => { _scope_reason(); const $scope0_id = _scope_id(); let b = ""; - _html(`
    s${_escape(b)}${_el_resume($scope0_id, "a")}
    ${_escape(b)}${_el_resume($scope0_id, "b")}
    ${_el_resume($scope0_id, "c")}`); + _html(`
    s${_escape(b) || ""}${_el_resume($scope0_id, "a")}
    ${_escape(b) || ""}${_el_resume($scope0_id, "b")}
    ${_el_resume($scope0_id, "c")}`); _script($scope0_id, "a0"); writeScope($scope0_id, {}); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..3489aa52fef --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,23 @@ +// template.marko +const $template = ""; +const $walks = "b%b%b b"; +const $for_content__x = /*@__PURE__*/ _for_closure("#text/1", ($scope) => _text($scope["#text/0"], $scope._.x)); +const $for_content__setup = $for_content__x; +const $if_content__x = /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => _text($scope["#text/0"], $scope._.x)); +const $if_content__setup = $if_content__x; +const $x = /*@__PURE__*/ _let("x/3", ($scope) => { + $if_content__x($scope); + $for_content__x($scope); +}); +const $if = /*@__PURE__*/ _if("#text/0", " ", " ", $if_content__setup); +const $for = /*@__PURE__*/ _for_of("#text/1", " tail", "%", $for_content__setup); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/2"], "click", function() { + $x($scope, "filled"); +})); +function $setup($scope) { + $x($scope, ""); + $if($scope, true ? 0 : 1); + $for($scope, [[1]]); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..a8dabc01aec --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/dom.bundle.js @@ -0,0 +1,10 @@ +// template.marko +const $for_content__x = /*@__PURE__*/ _for_closure(1, ($scope) => _text($scope.a, $scope._.d)); +const $if_content__x = /*@__PURE__*/ _if_closure(0, 0, ($scope) => _text($scope.a, $scope._.d)); +const $x = /*@__PURE__*/ _let(3, ($scope) => { + $if_content__x($scope); + $for_content__x($scope); +}); +const $setup__script = _script("a0", ($scope) => _on($scope.c, "click", function() { + $x($scope, "filled"); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..a07c130272a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/html.bundle.debug.js @@ -0,0 +1,23 @@ +// template.marko +var template_default = _template("__tests__/template.marko", (input) => { + _scope_reason(); + const $scope0_id = _scope_id(); + let x = ""; + _if(() => { + if (true) { + const $scope1_id = _scope_id(); + _html(`${_escape(x) || ""}${_el_resume($scope1_id, "#text/0")}`); + writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:2"); + return 0; + } + }, $scope0_id, "#text/0", 1, 0, 0, 0, 1); + _for_of([1], (i) => { + const $scope2_id = _scope_id(); + _html(`${_escape(x) || ""}${_el_resume($scope2_id, "#text/0")} tail`); + writeScope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:2"); + }, 0, $scope0_id, "#text/1", 1, 0, 0); + _html(`${_el_resume($scope0_id, "#button/2")}`); + _script($scope0_id, "__tests__/template.marko_0"); + writeScope($scope0_id, {}, "__tests__/template.marko", 0); + _resume_branch($scope0_id); +}, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..b8a2c601f1c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/html.bundle.js @@ -0,0 +1,23 @@ +// template.marko +var template_default = _template("a", (input) => { + _scope_reason(); + const $scope0_id = _scope_id(); + let x = ""; + _if(() => { + { + const $scope1_id = _scope_id(); + _html(`${_escape(x) || ""}${_el_resume($scope1_id, "a")}`); + writeScope($scope1_id, { _: _scope_with_id($scope0_id) }); + return 0; + } + }, $scope0_id, "a", 1, 0, 0, 0, 1); + _for_of([1], (i) => { + const $scope2_id = _scope_id(); + _html(`${_escape(x) || ""}${_el_resume($scope2_id, "a")} tail`); + writeScope($scope2_id, { _: _scope_with_id($scope0_id) }); + }, 0, $scope0_id, "b", 1, 0, 0); + _html(`${_el_resume($scope0_id, "c")}`); + _script($scope0_id, "a0"); + writeScope($scope0_id, {}); + _resume_branch($scope0_id); +}, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/render.debug.md new file mode 100644 index 00000000000..011fd970ffc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/render.debug.md @@ -0,0 +1,23 @@ +# Render +```html +tail + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +filledfilled tail + +``` +## Change +``` +UPDATE: ::text@0 "" => "filled" +UPDATE: ::text@6 "" => "filled" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/render.md new file mode 100644 index 00000000000..011fd970ffc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/render.md @@ -0,0 +1,23 @@ +# Render +```html +tail + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +filledfilled tail + +``` +## Change +``` +UPDATE: ::text@0 "" => "filled" +UPDATE: ::text@6 "" => "filled" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..313a00a9f64 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/writes.debug.html @@ -0,0 +1,16 @@ + + tail + diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/writes.html new file mode 100644 index 00000000000..36c1531a2ad --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/__snapshots__/writes.html @@ -0,0 +1,14 @@ + + tail + diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/sizes.json new file mode 100644 index 00000000000..c8d40d72a02 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/sizes.json @@ -0,0 +1,12 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 2928, + "brotli": 1463 + } + }, + "html": { + "min": 409, + "brotli": 280 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/template.marko b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/template.marko new file mode 100644 index 00000000000..aa1db56937b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/template.marko @@ -0,0 +1,4 @@ + +${x} +${x} tail + diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/test.ts b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/test.ts new file mode 100644 index 00000000000..c4fce053c48 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-empty-at-section-start/test.ts @@ -0,0 +1,10 @@ +import type { TestConfig } from "../../main.test"; + +export const config: TestConfig = { + steps: [ + {}, + (document: Document) => { + document.querySelector("button")!.click(); + }, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.debug.js index 0f0d0d4434c..080165fd323 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.debug.js @@ -2,7 +2,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_reason = _scope_reason(), $sg__input_x = _serialize_guard($scope0_reason, 0); const $scope0_id = _scope_id(); - _html(`${_sep($sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "#text/0", $sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "#text/1", $sg__input_x)}
    a
    ${_escape(input.x)}${_el_resume($scope0_id, "#text/2", $sg__input_x)}Hello Text <a/>${_sep($sg__input_x)}${_unescaped(input.x)}${_el_resume($scope0_id, "#text/3", $sg__input_x)}Hello HTML hi${_escape_script(` + _html(`${_sep($sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "#text/0", $sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "#text/1", $sg__input_x)}
    a
    ${_escape(input.x) || _sep($sg__input_x)}${_el_resume($scope0_id, "#text/2", $sg__input_x)}Hello Text <a/>${_sep($sg__input_x)}${_unescaped(input.x)}${_el_resume($scope0_id, "#text/3", $sg__input_x)}Hello HTML hi${_escape_script(` ${_to_text("'Hello <\/script>'")} `)}<\/script>${_escape_style(` ${_to_text(".test { content: 'Hello ' }")} diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.js index b78bc9a2c95..214f2d17451 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholders/__snapshots__/html.bundle.js @@ -2,7 +2,7 @@ var template_default = _template("a", (input) => { const $scope0_reason = _scope_reason(), $sg__input_x = _serialize_guard($scope0_reason, 0); const $scope0_id = _scope_id(); - _html(`${_sep($sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "a", $sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "b", $sg__input_x)}
    a
    ${_escape(input.x)}${_el_resume($scope0_id, "c", $sg__input_x)}Hello Text <a/>${_sep($sg__input_x)}${_unescaped(input.x)}${_el_resume($scope0_id, "d", $sg__input_x)}Hello HTML hi${_escape_script(` + _html(`${_sep($sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "a", $sg__input_x)}${_escape(input.x)}${_el_resume($scope0_id, "b", $sg__input_x)}
    a
    ${_escape(input.x) || _sep($sg__input_x)}${_el_resume($scope0_id, "c", $sg__input_x)}Hello Text <a/>${_sep($sg__input_x)}${_unescaped(input.x)}${_el_resume($scope0_id, "d", $sg__input_x)}Hello HTML hi${_escape_script(` ${_to_text("'Hello <\/script>'")} `)}<\/script>${_escape_style(` ${_to_text(".test { content: 'Hello ' }")} diff --git a/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.debug.js index d75fb35ddf6..cbdee6cdf04 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.debug.js @@ -6,7 +6,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _html("
    "); _for_of(children, (child) => { const $scope1_id = _scope_id(); - _html(`${_escape(child.text)}${_el_resume($scope1_id, "#text/0", $sg__input_children)}`); + _html(`${_escape(child.text) || _sep($sg__input_children)}${_el_resume($scope1_id, "#text/0", $sg__input_children)}`); $si__input_children && writeScope($scope1_id, {}, "__tests__/template.marko", "3:4"); }, function(c) { return c.id; diff --git a/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.js index 05b7419fbfc..3c2158ae7bc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.bundle.js @@ -6,7 +6,7 @@ var template_default = _template("a", (input) => { _html("
    "); _for_of(children, (child) => { const $scope1_id = _scope_id(); - _html(`${_escape(child.text)}${_el_resume($scope1_id, "a", $sg__input_children)}`); + _html(`${_escape(child.text) || _sep($sg__input_children)}${_el_resume($scope1_id, "a", $sg__input_children)}`); $si__input_children && writeScope($scope1_id, {}); }, function(c) { return c.id; diff --git a/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.debug.js index 963fd7c2698..6dc858951b0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.debug.js @@ -1,11 +1,11 @@ // template.marko var template_default = _template("__tests__/template.marko", (input) => { - const $scope0_reason = _scope_reason(); + const $scope0_reason = _scope_reason(), $sg__input_note = _serialize_guard($scope0_reason, 0); const $scope0_id = _scope_id(); let reveal = false; _html(`${_el_resume($scope0_id, "#button/0")}`); _show_start(reveal, 1); - _html(`${_escape(input.note)}${_el_resume($scope0_id, "#text/2", _serialize_guard($scope0_reason, 0))}`); + _html(`${_escape(input.note) || _sep($sg__input_note)}${_el_resume($scope0_id, "#text/2", $sg__input_note)}`); _show_end($scope0_id, "#text/4", reveal); _script($scope0_id, "__tests__/template.marko_0"); writeScope($scope0_id, { reveal }, "__tests__/template.marko", 0, { reveal: "1:6" }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.js index 959a76aa2ea..b641c34ef5f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/show-tag-empty-body/__snapshots__/html.bundle.js @@ -1,11 +1,11 @@ // template.marko var template_default = _template("a", (input) => { - const $scope0_reason = _scope_reason(); + const $sg__input_note = _serialize_guard(_scope_reason(), 0); const $scope0_id = _scope_id(); let reveal = false; _html(`${_el_resume($scope0_id, "a")}`); _show_start(reveal, 1); - _html(`${_escape(input.note)}${_el_resume($scope0_id, "c", _serialize_guard($scope0_reason, 0))}`); + _html(`${_escape(input.note) || _sep($sg__input_note)}${_el_resume($scope0_id, "c", $sg__input_note)}`); _show_end($scope0_id, "e", reveal); _script($scope0_id, "a0"); writeScope($scope0_id, { i: reveal }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.debug.js index b549ff5929f..683a60291af 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.debug.js @@ -25,9 +25,9 @@ var template_default = _template("__tests__/template.marko", (input) => { _html("LOADING..."); }, $scope0_id) }), catch: attrTag({ content: _content_resume("__tests__/template.marko_3*content", (err) => { - const $scope3_reason = _scope_reason(); + const $scope3_reason = _scope_reason(), $sg__err = _serialize_guard($scope3_reason, 0); const $scope3_id = _scope_id(); - _html(`${_escape(err)}${_el_resume($scope3_id, "#text/0", _serialize_guard($scope3_reason, 0))}`); + _html(`${_escape(err) || _sep($sg__err)}${_el_resume($scope3_id, "#text/0", $sg__err)}`); _serialize_if($scope3_reason, 0) && writeScope($scope3_id, {}, "__tests__/template.marko", "17:4"); }, $scope0_id) }) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.js index cf25854de18..d7efc303cac 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.bundle.js @@ -25,9 +25,9 @@ var template_default = _template("a", (input) => { _html("LOADING..."); }, $scope0_id) }), catch: attrTag({ content: _content_resume("a1", (err) => { - const $scope3_reason = _scope_reason(); + const $scope3_reason = _scope_reason(), $sg__err = _serialize_guard($scope3_reason, 0); const $scope3_id = _scope_id(); - _html(`${_escape(err)}${_el_resume($scope3_id, "a", _serialize_guard($scope3_reason, 0))}`); + _html(`${_escape(err) || _sep($sg__err)}${_el_resume($scope3_id, "a", $sg__err)}`); _serialize_if($scope3_reason, 0) && writeScope($scope3_id, {}); }, $scope0_id) }) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.debug.js index 50e30eef368..c957ee7e50c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.debug.js @@ -16,9 +16,9 @@ var template_default = _template("__tests__/template.marko", (input) => { _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "4:2")); _resume_branch($scope1_id); }, $scope0_id), { catch: attrTag({ content: _content_resume("__tests__/template.marko_2*content", (err) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__err = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(err)}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(err) || _sep($sg__err)}${_el_resume($scope2_id, "#text/0", $sg__err)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}, "__tests__/template.marko", "12:4"); }, $scope0_id) }) }); writeScope($scope0_id, { diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.js index cc7d84faa16..491929e87f9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch-state/__snapshots__/html.bundle.js @@ -14,9 +14,9 @@ var template_default = _template("a", (input) => { _subscribe($clickCount__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id), { catch: attrTag({ content: _content_resume("a0", (err) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__err = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(err)}${_el_resume($scope2_id, "a", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(err) || _sep($sg__err)}${_el_resume($scope2_id, "a", $sg__err)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}); }, $scope0_id) }) }); writeScope($scope0_id, { diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.debug.js index 647266422af..10260870a9f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.debug.js @@ -12,9 +12,9 @@ var template_default = _template("__tests__/template.marko", (input) => { _script($scope1_id, "__tests__/template.marko_1"); writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:2"); }, $scope0_id), { catch: attrTag({ content: _content_resume("__tests__/template.marko_2*content", (err) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__err_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(err.message)}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(err.message) || _sep($sg__err_message)}${_el_resume($scope2_id, "#text/0", $sg__err_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}, "__tests__/template.marko", "7:4"); }, $scope0_id) }) }); _html(`
    ${_el_resume($scope0_id, "#div/2")}`); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.js index 7df53be83f8..91bf36ca1a8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-catch/__snapshots__/html.bundle.js @@ -12,9 +12,9 @@ var template_default = _template("a", (input) => { _script($scope1_id, "a2"); writeScope($scope1_id, { _: _scope_with_id($scope0_id) }); }, $scope0_id), { catch: attrTag({ content: _content_resume("a0", (err) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__err_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(err.message)}${_el_resume($scope2_id, "a", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(err.message) || _sep($sg__err_message)}${_el_resume($scope2_id, "a", $sg__err_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}); }, $scope0_id) }) }); _html(`
    ${_el_resume($scope0_id, "c")}`); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.debug.js index 3940be40218..a8a0015c674 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.debug.js @@ -10,9 +10,9 @@ var template_default = _template("__tests__/template.marko", (input) => { throw new Error("ERROR!"); })())}`); }, $scope0_id), { catch: attrTag({ content: _content_resume("__tests__/template.marko_2*content", (err) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__err_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(err.message)}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(err.message) || _sep($sg__err_message)}${_el_resume($scope2_id, "#text/0", $sg__err_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}, "__tests__/template.marko", "5:3"); }, $scope0_id) }) }); _html("After"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.js index aa1aa977052..322b452d644 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.bundle.js @@ -10,9 +10,9 @@ var template_default = _template("a", (input) => { throw new Error("ERROR!"); })())}`); }, $scope0_id), { catch: attrTag({ content: _content_resume("a0", (err) => { - const $scope2_reason = _scope_reason(); + const $scope2_reason = _scope_reason(), $sg__err_message = _serialize_guard($scope2_reason, 0); const $scope2_id = _scope_id(); - _html(`${_escape(err.message)}${_el_resume($scope2_id, "a", _serialize_guard($scope2_reason, 0))}`); + _html(`${_escape(err.message) || _sep($sg__err_message)}${_el_resume($scope2_id, "a", $sg__err_message)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, {}); }, $scope0_id) }) }); _html("After"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.debug.js index f70b7883b96..ff6f2e29b7b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.debug.js @@ -21,8 +21,8 @@ var template_default = _template("__tests__/template.marko", (input) => { }, $scope0_id) }; const Message = { content: _content("__tests__/template.marko_2*content", (input) => { const $scope2_id = _scope_id(); - const $scope2_reason = _scope_reason(); - _html(`${_escape(input.before + input.after)}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope2_reason, 0))}`); + const $scope2_reason = _scope_reason(), $sg__input_before__OR__input_after = _serialize_guard($scope2_reason, 0); + _html(`${_escape(input.before + input.after) || _sep($sg__input_before__OR__input_after)}${_el_resume($scope2_id, "#text/0", $sg__input_before__OR__input_after)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, { input_before: _serialize_if($scope2_reason, 2) && input.before, input_after: _serialize_if($scope2_reason, 1) && input.after diff --git a/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.js index 1ee38e384b4..83a4e9fd3e5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/unused-dynamic-tag-body-serialize-reason/__snapshots__/html.bundle.js @@ -17,8 +17,8 @@ var template_default = _template("a", (input) => { }, $scope0_id) }; const Message = { content: _content("a2", (input) => { const $scope2_id = _scope_id(); - const $scope2_reason = _scope_reason(); - _html(`${_escape(input.before + input.after)}${_el_resume($scope2_id, "a", _serialize_guard($scope2_reason, 0))}`); + const $scope2_reason = _scope_reason(), $sg__input_before__OR__input_after = _serialize_guard($scope2_reason, 0); + _html(`${_escape(input.before + input.after) || _sep($sg__input_before__OR__input_after)}${_el_resume($scope2_id, "a", $sg__input_before__OR__input_after)}`); _serialize_if($scope2_reason, 0) && writeScope($scope2_id, { d: _serialize_if($scope2_reason, 2) && input.before, e: _serialize_if($scope2_reason, 1) && input.after diff --git a/packages/runtime-tags/src/translator/visitors/constants/sibling-text.ts b/packages/runtime-tags/src/translator/visitors/constants/sibling-text.ts index af4285225d2..bd8483376fe 100644 --- a/packages/runtime-tags/src/translator/visitors/constants/sibling-text.ts +++ b/packages/runtime-tags/src/translator/visitors/constants/sibling-text.ts @@ -1,9 +1,6 @@ export const None = 0; export const Before = 1; export const After = 2; -// A non-text node (element/comment) directly precedes: no text to merge -// with, but resume must not claim that node when the text renders empty. -export const NodeBefore = 3; type Self = typeof import("./sibling-text"); export type Value = Self[keyof Self]; diff --git a/packages/runtime-tags/src/translator/visitors/placeholder.ts b/packages/runtime-tags/src/translator/visitors/placeholder.ts index a88c711500a..e75ffa312e6 100644 --- a/packages/runtime-tags/src/translator/visitors/placeholder.ts +++ b/packages/runtime-tags/src/translator/visitors/placeholder.ts @@ -38,11 +38,13 @@ import { scopeIdentifier } from "./program"; const kNodeBinding = Symbol("placeholder node binding"); const kSiblingText = Symbol("placeholder has sibling text"); +const kSeparateWhenEmpty = Symbol("placeholder must resume as its own node"); type SiblingText = SiblingText.Value; declare module "@marko/compiler/dist/types" { export interface MarkoPlaceholderExtra { [kNodeBinding]?: Binding; [kSiblingText]?: SiblingText; + [kSeparateWhenEmpty]?: true; } } @@ -162,22 +164,27 @@ function translateExit(placeholder: t.NodePath) { const markerSerializeReason = nodeBinding && getSerializeReason(section, nodeBinding); - if (isHTML && markerSerializeReason) { - if (siblingText === SiblingText.Before) { - writeSeparator(write, section, markerSerializeReason); - } else if (siblingText === SiblingText.NodeBefore) { - // A preceding element/comment would be claimed as the text node when - // the value serializes empty, so it gets the same protective separator. - writeSeparator(write, section, markerSerializeReason); - } - } - if (isHTML) { - write`${ + let text = method === "_escape" ? buildEscapedTextExpression(value) - : callRuntime(method as HTMLMethod | DOMMethod, value) - }`; + : callRuntime(method as HTMLMethod | DOMMethod, value); + + if (markerSerializeReason) { + if (siblingText === SiblingText.Before) { + // Sibling text merges into this node, so it always needs separating. + write`${buildSeparator(section, markerSerializeReason)}`; + } else if (extra[kSeparateWhenEmpty]) { + // A sibling node is only claimed when there is no text node at all. + text = t.logicalExpression( + "||", + text, + buildSeparator(section, markerSerializeReason), + ); + } + } + + write`${text}`; if (nodeBinding) { writer.markNode(placeholder, nodeBinding, markerSerializeReason); } @@ -254,23 +261,18 @@ function buildEscapedTextExpression(value: t.Expression): t.Expression { } } -// The `` separator keeps resume from claiming the previous node as the -// placeholder's text node when the serialized text is empty. -function writeSeparator( - write: ReturnType, +// An empty comment for resume to replace with the placeholder's own text node. +function buildSeparator( section: Section, reason: Exclude, undefined | false>, ) { - if (reason === true || reason.state) { - write``; - } else { - write`${callRuntime("_sep", getSerializeGuard(section, reason, true))}`; - } + return reason === true || reason.state + ? t.stringLiteral("") + : callRuntime("_sep", getSerializeGuard(section, reason, true)); } function analyzeSiblingText(placeholder: t.NodePath) { const placeholderExtra = placeholder.node.extra!; - let hasNodeBefore = false; let prev = placeholder.getPrevSibling(); let prevParent: t.NodePath = placeholder.parentPath; for (;;) { @@ -298,12 +300,19 @@ function analyzeSiblingText(placeholder: t.NodePath) { ) { return (placeholderExtra[kSiblingText] = SiblingText.Before); } else { - hasNodeBefore = true; + placeholderExtra[kSeparateWhenEmpty] = true; break; } } - if (!prev.node && prevParent.isProgram()) { - return (placeholderExtra[kSiblingText] = SiblingText.Before); + if (!prev.node) { + if (prevParent.isProgram()) { + return (placeholderExtra[kSiblingText] = SiblingText.Before); + } + // A section's content is resumed as its own range, so its first node + // cannot be borrowed from whatever the section was rendered against. + if (prevParent.node.extra?.section) { + placeholderExtra[kSeparateWhenEmpty] = true; + } } let next = placeholder.getNextSibling(); let nextParent: t.NodePath = placeholder.parentPath; @@ -337,9 +346,7 @@ function analyzeSiblingText(placeholder: t.NodePath) { return (placeholderExtra[kSiblingText] = SiblingText.After); } - return (placeholderExtra[kSiblingText] = hasNodeBefore - ? SiblingText.NodeBefore - : SiblingText.None); + return (placeholderExtra[kSiblingText] = SiblingText.None); } // Returns the owner tag when `parent` is the body of a tag that inlines its