diff --git a/.sizes.json b/.sizes.json index 668e809f6..4c47efd3e 100644 --- a/.sizes.json +++ b/.sizes.json @@ -7,9 +7,9 @@ { "name": "*", "total": { - "min": 12300, - "gzip": 5180, - "brotli": 4738 + "min": 12304, + "gzip": 5179, + "brotli": 4751 } }, { @@ -35,17 +35,17 @@ "user": { "min": 207, "gzip": 182, - "brotli": 152 + "brotli": 153 }, "runtime": { - "min": 2635, - "gzip": 1333, - "brotli": 1191 + "min": 2639, + "gzip": 1330, + "brotli": 1188 }, "total": { - "min": 2842, - "gzip": 1515, - "brotli": 1343 + "min": 2846, + "gzip": 1512, + "brotli": 1341 } }, { @@ -71,16 +71,16 @@ "user": { "min": 943, "gzip": 585, - "brotli": 538 + "brotli": 537 }, "runtime": { - "min": 7966, - "gzip": 3606, - "brotli": 3279 + "min": 7970, + "gzip": 3605, + "brotli": 3280 }, "total": { - "min": 8909, - "gzip": 4191, + "min": 8913, + "gzip": 4190, "brotli": 3817 } } diff --git a/packages/runtime/src/dom/hydrate.ts b/packages/runtime/src/dom/hydrate.ts index 29fce157c..00bd16981 100644 --- a/packages/runtime/src/dom/hydrate.ts +++ b/packages/runtime/src/dom/hydrate.ts @@ -96,7 +96,7 @@ export function init(runtimeId = "M" /* [a-zA-Z0-9]+ */) { const data = nodeValue.slice(nodeValue.indexOf(" ") + 1); if (token === HydrateSymbols.NODE) { - scope[data] = currentNode.nextSibling; + scope[data] = currentNode.previousSibling; } else if (token === HydrateSymbols.SECTION_START) { stack.push(currentScopeId); currentScopeId = scopeId; diff --git a/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/template.js index 30772b12c..a31828941 100644 --- a/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _customTag from "./components/custom-tag/index.marko"; const _renderer = ({ x @@ -6,7 +6,6 @@ const _renderer = ({ const _scope = _nextScopeId(); let _thing; const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); if (x) { const _scope = _nextScopeId(); _thing = { diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/template.js index 5fc658618..a723d390f 100644 --- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/template.js @@ -1,10 +1,9 @@ -import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _hello from "./components/hello/index.marko"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const _item = []; const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); for (const a in { a: 1, b: 2 diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected/template.js index eb0894406..84b8a6946 100644 --- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected/template.js @@ -1,9 +1,8 @@ -import { markHydrateNode as _markHydrateNode, write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ x }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); _dynamicTag(x, { header: { class: "my-header", diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/template.js index e4e1a26ca..916473912 100644 --- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _hello from "./components/hello/index.marko"; const _renderer = ({ x @@ -6,12 +6,11 @@ const _renderer = ({ const _scope = _nextScopeId(); let _item; const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); if (x) { const _scope = _nextScopeId(); _item = { renderBody(y) { - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(y)}`); + _write(`${_escapeXML(y)}${_markHydrateNode(_scope, 0)}`); } }; } diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/template.js index 9f8c4df29..7898db27a 100644 --- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/template.js @@ -1,14 +1,12 @@ -import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, escapeXML as _escapeXML, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _hello from "./components/hello/index.marko"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const _col = []; const _scope = _nextScopeId(); const _item = []; - _write(`${_markHydrateNode(_scope, 0)}`); for (const color of ["red", "blue", "green"]) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); if (color === "red") { const _scope = _nextScopeId(); _item.push({ @@ -32,19 +30,17 @@ const _renderer = (input, _tagVar) => { } _maybeFlush(); } - _write(`${_markHydrateNode(_scope, 0)}`); let _i = 0; for (const col of [["a", "b"], ["c", "d"]]) { let i = _i++; const _scope = _nextScopeId(); const _row = []; - _write(`${_markHydrateNode(_scope, 0)}`); for (const row of col) { const _scope = _nextScopeId(); _row.push({ row: row, renderBody() { - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(row)}`); + _write(`${_escapeXML(row)}${_markHydrateNode(_scope, 0)}`); } }); _maybeFlush(); diff --git a/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/template.js index d0807c6e9..e609e6911 100644 --- a/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { markHydrateNode as _markHydrateNode, classAttr as _classAttr, write as _write, nextScopeId as _nextScopeId, dynamicTag as _dynamicTag, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { classAttr as _classAttr, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, dynamicTag as _dynamicTag, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _customTag from "./components/custom-tag.marko"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); @@ -6,10 +6,10 @@ const _renderer = (input, _tagVar) => { c, d } = input; - _write(`${_markHydrateNode(_scope, 0)}
`); + }])}>${_markHydrateNode(_scope, 0)}
`); _customTag({ class: ["a", { b: c, @@ -25,7 +25,6 @@ const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); } }); - _write(`${_markHydrateNode(_scope, 1)}`); _dynamicTag(input.test, { class: ["a", { b: c, diff --git a/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected/template.js index f2c88986e..b5098a62d 100644 --- a/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected/template.js @@ -1,7 +1,7 @@ -import { markHydrateNode as _markHydrateNode, classAttr as _classAttr, attr as _attr, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { classAttr as _classAttr, attr as _attr, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/template.js index 381f7d739..f504f0c35 100644 --- a/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/template.js @@ -1,13 +1,13 @@ -import { markHydrateNode as _markHydrateNode, styleAttr as _styleAttr, write as _write, nextScopeId as _nextScopeId, dynamicTag as _dynamicTag, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { styleAttr as _styleAttr, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, dynamicTag as _dynamicTag, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _customTag from "./components/custom-tag.marko"; const _renderer = ({ color, test }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}
`); + })}>${_markHydrateNode(_scope, 0)}
`); _customTag({ style: { color: color @@ -30,7 +30,6 @@ const _renderer = ({ const _scope = _nextScopeId(); } }); - _write(`${_markHydrateNode(_scope, 1)}`); _dynamicTag(test, { style: { color: "green" diff --git a/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected/template.js index 3c5625106..919bd0905 100644 --- a/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected/template.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, attr as _attr, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { attr as _attr, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ name }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/html.expected/template.js index 1e2a7982a..a78160238 100644 --- a/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/html.expected/template.js @@ -1,10 +1,10 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const x = 1; const y = x * 2; const z = y * 3; - _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(z)}
`); + _write(`
${_escapeXML(z)}${_markHydrateNode(_scope, 0)}
`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/hydrate.expected.md index 637cd719b..e5ba77a1f 100644 --- a/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/hydrate.expected.md @@ -4,8 +4,8 @@
- 6 +
diff --git a/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/ssr.expected.md index fecf646b9..d7de23489 100644 --- a/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-chain/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
6
+
6
# Render "End" @@ -8,8 +8,8 @@
- 6 +
@@ -21,6 +21,6 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 -inserted #document/html0/body1/div0/#comment0 -inserted #document/html0/body1/div0/#text1 +inserted #document/html0/body1/div0/#text0 +inserted #document/html0/body1/div0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected/components/my-button.js b/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected/components/my-button.js index 36bf3d12a..e57746634 100644 --- a/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected/components/my-button.js +++ b/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected/components/my-button.js @@ -1,10 +1,10 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ onClick, text }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-component-attrs/components/my-button.marko_0_onClick"); _writeHydrateScope(_scope, { 2: onClick diff --git a/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/components/my-button.js b/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/components/my-button.js index 12d74eeb8..09a58e530 100644 --- a/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/components/my-button.js +++ b/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/components/my-button.js @@ -1,12 +1,12 @@ -import { markHydrateNode as _markHydrateNode, write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, dynamicTag as _dynamicTag, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ onClick, renderBody }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}"); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-component-renderBody/components/my-button.marko_0_onClick"); _writeHydrateScope(_scope, { 7: onClick diff --git a/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/template.js index bdf9b230d..404301f50 100644 --- a/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-component-renderBody/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _myButton from "./components/my-button.marko"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); @@ -9,7 +9,7 @@ const _renderer = (input, _tagVar) => { }, renderBody() { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(clickCount)}`); + _write(`${_escapeXML(clickCount)}${_markHydrateNode(_scope, 0)}`); } }); }; diff --git a/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected/components/counter.js b/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected/components/counter.js index ac1e3e952..d2ce6dfef 100644 --- a/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected/components/counter.js +++ b/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected/components/counter.js @@ -1,8 +1,8 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const clickCount = 0; - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-component/components/counter.marko_0_clickCount"); _writeHydrateScope(_scope, { 2: clickCount diff --git a/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/hydrate.expected.md index 21a996c2f..531609929 100644 --- a/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/hydrate.expected.md @@ -4,11 +4,11 @@
- +
+
# Render "End" @@ -8,11 +8,11 @@
- +
+ The count is 0 # Render "End" @@ -7,18 +7,19 @@ - 0 # Render "End" @@ -7,17 +7,17 @@ - # Render "End" @@ -8,11 +8,11 @@
- +
@@ -25,14 +25,14 @@ container.querySelector("button").click(); ```html - + @@ -42,7 +42,7 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "0" => "1" +#document/html0/body1/button0/#text0: "0" => "1" ``` @@ -50,14 +50,14 @@ container.querySelector("button").click(); container.querySelector("button").click(); ```html - + @@ -67,7 +67,7 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "1" => "2" +#document/html0/body1/button0/#text0: "1" => "2" ``` @@ -75,14 +75,14 @@ container.querySelector("button").click(); container.querySelector("button").click(); ```html - + @@ -92,5 +92,5 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "2" => "3" +#document/html0/body1/button0/#text0: "2" => "3" ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-fn-with-block/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/basic-fn-with-block/__snapshots__/ssr.expected.md index f2d305092..a39c8af12 100644 --- a/packages/translator/src/__tests__/fixtures/basic-fn-with-block/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-fn-with-block/__snapshots__/ssr.expected.md @@ -1,17 +1,17 @@ # Write - + # Render "End" ```html - + @@ -21,13 +21,13 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/button0 -inserted #document/html1/body1/button0/#comment0 -inserted #document/html1/body1/button0/#text1 -inserted #document/html1/body1/script1 -inserted #document/html1/body1/script1/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/button0 +inserted #document/html0/body1/button0/#text0 +inserted #document/html0/body1/button0/#comment1 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/html.expected/template.js index 451d0302f..d8e5339be 100644 --- a/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/html.expected/template.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const a = [0]; const b = 1; - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/template.marko_0_a_b"); _writeHydrateScope(_scope, { 2: a, diff --git a/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/hydrate.expected.md index 567c41118..f62738773 100644 --- a/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/hydrate.expected.md @@ -1,13 +1,13 @@ # Render {} ```html - + @@ -25,14 +25,14 @@ container.querySelector("button").click(); ```html - + @@ -42,5 +42,5 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "0" => "1" +#document/html0/body1/button0/#text0: "0" => "1" ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/ssr.expected.md index ec392a4ee..aaf56211b 100644 --- a/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-handler-multi-ref-nested/__snapshots__/ssr.expected.md @@ -1,17 +1,17 @@ # Write - + # Render "End" ```html - + @@ -21,13 +21,13 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/button0 -inserted #document/html1/body1/button0/#comment0 -inserted #document/html1/body1/button0/#text1 -inserted #document/html1/body1/script1 -inserted #document/html1/body1/script1/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/button0 +inserted #document/html0/body1/button0/#text0 +inserted #document/html0/body1/button0/#comment1 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/html.expected/template.js index d7d6ce6f5..46c313eb9 100644 --- a/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/html.expected/template.js @@ -1,8 +1,8 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const data = 0; - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-handler-refless/template.marko_0"); }; export default _renderer; diff --git a/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/hydrate.expected.md index 904a8ffb8..70e292f43 100644 --- a/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/hydrate.expected.md @@ -1,13 +1,13 @@ # Render {} ```html - + @@ -25,14 +25,14 @@ container.querySelector("button").click(); ```html - + @@ -42,5 +42,5 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "0" => "1" +#document/html0/body1/button0/#text0: "0" => "1" ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/ssr.expected.md index f7ad2ca4d..8ecc44a6f 100644 --- a/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-handler-refless/__snapshots__/ssr.expected.md @@ -1,17 +1,17 @@ # Write - + # Render "End" ```html - + @@ -21,13 +21,13 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/button0 -inserted #document/html1/body1/button0/#comment0 -inserted #document/html1/body1/button0/#text1 -inserted #document/html1/body1/script1 -inserted #document/html1/body1/script1/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/button0 +inserted #document/html0/body1/button0/#text0 +inserted #document/html0/body1/button0/#comment1 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/html.expected/components/comments.js b/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/html.expected/components/comments.js index 424b483be..c3111fa32 100644 --- a/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/html.expected/components/comments.js +++ b/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/html.expected/components/comments.js @@ -1,18 +1,18 @@ -import { markHydrateNode as _markHydrateNode, write as _write, attr as _attr, escapeXML as _escapeXML, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, attr as _attr, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _comments from "./comments.marko"; const _renderer = ({ comments, path = "c" }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}
    `); + _write("
      "); let _i = 0; for (const comment of comments) { let i = _i++; const _scope = _nextScopeId(); const id = `${path}-${i}`; const open = true; - _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 1)}${_escapeXML(comment.text)}${_markHydrateNode(_scope, 2)}${_markHydrateNode(_scope, 4)}`); + _write(`${_escapeXML(comment.text)}${_markHydrateNode(_scope, 1)}${_markHydrateNode(_scope, 2)}`); if (comment.comments) { const _scope = _nextScopeId(); _comments({ @@ -23,14 +23,14 @@ const _renderer = ({ } }); } - _write(""); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/components/comments.marko_1_open"); _writeHydrateScope(_scope, { 13: open }); _maybeFlush(); } - _write("
    "); + _write(`
${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/ssr.expected.md index b5e36632d..fa3c6a45a 100644 --- a/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-inert-collapsible-tree/__snapshots__/ssr.expected.md @@ -1,63 +1,60 @@ # Write -
  • Hello World
    • testing 123
  • Goodbye World
+
  • Hello World
    • testing 123
  • Goodbye World
# Render "End" ```html -
    -
  • - Hello World + - - - +
      -
    • - testing 123 + - - +
    • +
    +
  • - +
  • - Goodbye World + - - +
  • +
+ @@ -67,43 +64,40 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/ul0 -inserted #document/html1/body1/ul0/#comment0 -inserted #document/html1/body1/ul0/li1 -inserted #document/html1/body1/ul0/li1/span0 -inserted #document/html1/body1/ul0/li1/span0/#comment0 -inserted #document/html1/body1/ul0/li1/span0/#text1 -inserted #document/html1/body1/ul0/li1/#comment1 -inserted #document/html1/body1/ul0/li1/button2 -inserted #document/html1/body1/ul0/li1/button2/#comment0 -inserted #document/html1/body1/ul0/li1/button2/#text1 -inserted #document/html1/body1/ul0/li1/#comment3 -inserted #document/html1/body1/ul0/li1/#comment4 -inserted #document/html1/body1/ul0/li1/ul5 -inserted #document/html1/body1/ul0/li1/ul5/#comment0 -inserted #document/html1/body1/ul0/li1/ul5/li1 -inserted #document/html1/body1/ul0/li1/ul5/li1/span0 -inserted #document/html1/body1/ul0/li1/ul5/li1/span0/#comment0 -inserted #document/html1/body1/ul0/li1/ul5/li1/span0/#text1 -inserted #document/html1/body1/ul0/li1/ul5/li1/#comment1 -inserted #document/html1/body1/ul0/li1/ul5/li1/button2 -inserted #document/html1/body1/ul0/li1/ul5/li1/button2/#comment0 -inserted #document/html1/body1/ul0/li1/ul5/li1/button2/#text1 -inserted #document/html1/body1/ul0/li1/ul5/li1/#comment3 -inserted #document/html1/body1/ul0/#comment2 -inserted #document/html1/body1/ul0/li3 -inserted #document/html1/body1/ul0/li3/span0 -inserted #document/html1/body1/ul0/li3/span0/#comment0 -inserted #document/html1/body1/ul0/li3/span0/#text1 -inserted #document/html1/body1/ul0/li3/#comment1 -inserted #document/html1/body1/ul0/li3/button2 -inserted #document/html1/body1/ul0/li3/button2/#comment0 -inserted #document/html1/body1/ul0/li3/button2/#text1 -inserted #document/html1/body1/ul0/li3/#comment3 -inserted #document/html1/body1/script1 -inserted #document/html1/body1/script1/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/ul0 +inserted #document/html0/body1/ul0/li0 +inserted #document/html0/body1/ul0/li0/span0 +inserted #document/html0/body1/ul0/li0/span0/#text0 +inserted #document/html0/body1/ul0/li0/span0/#comment1 +inserted #document/html0/body1/ul0/li0/button1 +inserted #document/html0/body1/ul0/li0/button1/#text0 +inserted #document/html0/body1/ul0/li0/button1/#comment1 +inserted #document/html0/body1/ul0/li0/#comment2 +inserted #document/html0/body1/ul0/li0/ul3 +inserted #document/html0/body1/ul0/li0/ul3/li0 +inserted #document/html0/body1/ul0/li0/ul3/li0/span0 +inserted #document/html0/body1/ul0/li0/ul3/li0/span0/#text0 +inserted #document/html0/body1/ul0/li0/ul3/li0/span0/#comment1 +inserted #document/html0/body1/ul0/li0/ul3/li0/button1 +inserted #document/html0/body1/ul0/li0/ul3/li0/button1/#text0 +inserted #document/html0/body1/ul0/li0/ul3/li0/button1/#comment1 +inserted #document/html0/body1/ul0/li0/ul3/li0/#comment2 +inserted #document/html0/body1/ul0/li0/ul3/#comment1 +inserted #document/html0/body1/ul0/li0/#comment4 +inserted #document/html0/body1/ul0/#comment1 +inserted #document/html0/body1/ul0/li2 +inserted #document/html0/body1/ul0/li2/span0 +inserted #document/html0/body1/ul0/li2/span0/#text0 +inserted #document/html0/body1/ul0/li2/span0/#comment1 +inserted #document/html0/body1/ul0/li2/button1 +inserted #document/html0/body1/ul0/li2/button1/#text0 +inserted #document/html0/body1/ul0/li2/button1/#comment1 +inserted #document/html0/body1/ul0/li2/#comment2 +inserted #document/html0/body1/ul0/#comment3 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/components/layout.js b/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/components/layout.js index 3bb5e541e..f9a545266 100644 --- a/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/components/layout.js +++ b/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/components/layout.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ renderBody }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); + _write(""); _dynamicTag(renderBody, null); _write(""); }; diff --git a/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/template.js index 4eca2a5f5..2cb3b2dbf 100644 --- a/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _layout from "./components/layout.marko"; const _renderer = ({ name @@ -7,7 +7,7 @@ const _renderer = ({ _layout({ renderBody() { const _scope = _nextScopeId(); - _write(`

Hello ${_markHydrateNode(_scope, 0)}${_escapeXML(name)}

`); + _write(`

Hello ${_escapeXML(name)}${_markHydrateNode(_scope, 0)}

`); } }); }; diff --git a/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/ssr.expected.md index 892ec7368..96c29ba82 100644 --- a/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-layout/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -

Hello World

+

Hello World

# Render "End" @@ -7,11 +7,11 @@ -

Hello - + World +

@@ -22,9 +22,9 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 -inserted #document/html0/body1/#comment0 -inserted #document/html0/body1/h11 -inserted #document/html0/body1/h11/#text0 -inserted #document/html0/body1/h11/#comment1 -inserted #document/html0/body1/h11/#text2 +inserted #document/html0/body1/h10 +inserted #document/html0/body1/h10/#text0 +inserted #document/html0/body1/h10/#comment1 +inserted #document/html0/body1/h10/#text2 +inserted #document/html0/body1/h10/#comment3 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js index 51d23569b..3afcd6fe7 100644 --- a/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js @@ -1,11 +1,10 @@ -import { markHydrateNode as _markHydrateNode, write as _write, attr as _attr, escapeXML as _escapeXML, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { attr as _attr, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const selected = 0; - _write(`${_markHydrateNode(_scope, 0)}`); for (const num of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 1)}${_escapeXML(num)}`); + _write(`${_escapeXML(num)}${_markHydrateNode(_scope, 1)}${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-nested-scope-for/template.marko_1_num"); _writeHydrateScope(_scope, { 2: num diff --git a/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/html.expected/template.js index 35d52bbc3..7ef8c9dc4 100644 --- a/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/html.expected/template.js @@ -1,18 +1,18 @@ -import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const clickCount = 0; - _write(`
${_markHydrateNode(_scope, 0)}`); + _write("
"); if (clickCount < 3) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-nested-scope-if/template.marko_1_clickCount"); _writeHydrateScope(_scope, { 6: clickCount }); } else { const _scope = _nextScopeId(); - _write(`The button was clicked ${_markHydrateNode(_scope, 0)}${_escapeXML(clickCount)} times.`); + _write(`The button was clicked ${_escapeXML(clickCount)}${_markHydrateNode(_scope, 0)} times.`); } _write("
"); }; diff --git a/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected/template.js index 78da92548..30206de2c 100644 --- a/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected/template.js @@ -1,15 +1,15 @@ -import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const id = 0; const items = []; - _write(`
${_markHydrateNode(_scope, 0)}`); + _write("
"); for (const item of items) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(item)}`); + _write(`${_escapeXML(item)}${_markHydrateNode(_scope, 0)}`); _maybeFlush(); } - _write(`${_markHydrateNode(_scope, 7)}${_markHydrateNode(_scope, 8)}
`); + _write(`${_markHydrateNode(_scope, 7)}${_markHydrateNode(_scope, 8)}
`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-push-pop-list/template.marko_0_items"); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-push-pop-list/template.marko_0_id_items"); _writeHydrateScope(_scope, { diff --git a/packages/translator/src/__tests__/fixtures/basic-scriptlet/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-scriptlet/__snapshots__/html.expected/template.js index 9c26742b3..5d71e3356 100644 --- a/packages/translator/src/__tests__/fixtures/basic-scriptlet/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-scriptlet/__snapshots__/html.expected/template.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const clickCount = 0; const doubleCount = clickCount * 2; - _write(`
${_markHydrateNode(_scope, 0)}
`); + _write(`
${_markHydrateNode(_scope, 0)}
`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-scriptlet/template.marko_0_clickCount"); _writeHydrateScope(_scope, { 2: clickCount diff --git a/packages/translator/src/__tests__/fixtures/basic-shared-node-ref/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-shared-node-ref/__snapshots__/html.expected/template.js index 410fab3cb..f52217a7a 100644 --- a/packages/translator/src/__tests__/fixtures/basic-shared-node-ref/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-shared-node-ref/__snapshots__/html.expected/template.js @@ -1,15 +1,15 @@ -import { markHydrateNode as _markHydrateNode, attr as _attr, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { attr as _attr, write as _write, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const open = true; const list = [1, 2, 3]; - _write(`${_markHydrateNode(_scope, 0)}`); + _write(``); for (const x of list) { const _scope = _nextScopeId(); - _write(`
  • ${_markHydrateNode(_scope, 0)}${_escapeXML(x)}
  • `); + _write(`
  • ${_escapeXML(x)}${_markHydrateNode(_scope, 0)}
  • `); _maybeFlush(); } - _write(`${_markHydrateNode(_scope, 7)}${_markHydrateNode(_scope, 8)}`); + _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 7)}${_markHydrateNode(_scope, 8)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-shared-node-ref/template.marko_0_list"); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-shared-node-ref/template.marko_0_open"); _writeHydrateScope(_scope, { diff --git a/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected/template.js index aa2d6d741..2dda120a2 100644 --- a/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected/template.js @@ -1,13 +1,13 @@ -import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, nextScopeId as _nextScopeId, markHydrateNode as _markHydrateNode, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const show = true; - _write(`
    ${_markHydrateNode(_scope, 0)}`); + _write("
    "); if (show) { const _scope = _nextScopeId(); _write("Hello!"); } - _write(`${_markHydrateNode(_scope, 6)}
    `); + _write(`${_markHydrateNode(_scope, 6)}
    `); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-toggle-show/template.marko_0_show"); _writeHydrateScope(_scope, { 7: show diff --git a/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected/template.js index f2a95d3e5..7993fcc63 100644 --- a/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected/template.js @@ -1,10 +1,10 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const unused_1 = 123; const unused_2 = 456; const clickCount = 0; - _write(`
    ${_markHydrateNode(_scope, 0)}
    `); + _write(`
    ${_markHydrateNode(_scope, 0)}
    `); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-unused-ref/template.marko_0_clickCount"); _writeHydrateScope(_scope, { 4: clickCount diff --git a/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/hydrate.expected.md index 89186a96f..147452d04 100644 --- a/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/hydrate.expected.md @@ -4,11 +4,11 @@
    - +
    +
    # Render "End" @@ -8,11 +8,11 @@
    - +
    @@ -28,11 +28,11 @@ container.querySelector("button").click(); - + @@ -42,7 +42,7 @@ container.querySelector("button").click(); # Mutations ``` -#document/html0/body1/button1/#text1: "0" => "1" +#document/html0/body1/button0/#text0: "0" => "1" ``` @@ -53,11 +53,11 @@ container.querySelector("button").click(); - + @@ -67,7 +67,7 @@ container.querySelector("button").click(); # Mutations ``` -#document/html0/body1/button1/#text1: "1" => "2" +#document/html0/body1/button0/#text0: "1" => "2" ``` @@ -78,11 +78,11 @@ container.querySelector("button").click(); - + @@ -92,5 +92,5 @@ container.querySelector("button").click(); # Mutations ``` -#document/html0/body1/button1/#text1: "2" => "3" +#document/html0/body1/button0/#text0: "2" => "3" ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/body-content/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/body-content/__snapshots__/ssr.expected.md index b04196d19..093cf0a2a 100644 --- a/packages/translator/src/__tests__/fixtures/body-content/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/body-content/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write - + # Render "End" @@ -7,11 +7,11 @@ - + @@ -24,10 +24,10 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 -inserted #document/html0/body1/#comment0 -inserted #document/html0/body1/button1 -inserted #document/html0/body1/button1/#comment0 -inserted #document/html0/body1/button1/#text1 +inserted #document/html0/body1/button0 +inserted #document/html0/body1/button0/#text0 +inserted #document/html0/body1/button0/#comment1 +inserted #document/html0/body1/#comment1 inserted #document/html0/body1/script2 inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/body-content/server.ts b/packages/translator/src/__tests__/fixtures/body-content/server.ts index ad26fa8fa..31743e0c1 100644 --- a/packages/translator/src/__tests__/fixtures/body-content/server.ts +++ b/packages/translator/src/__tests__/fixtures/body-content/server.ts @@ -27,7 +27,7 @@ const counter = () => { FancyButton({ renderBody() { const bodyScopeId = nextScopeId(); - write(`${markHydrateNode(bodyScopeId, 0)}${count}`); + write(`${count}${markHydrateNode(bodyScopeId, 0)}`); writeHydrateScope(bodyScopeId, { _: scope }); writeHydrateCall(bodyScopeId, "subscribe_clickCount$renderBody"); }, @@ -53,11 +53,11 @@ const FancyButton = ({ }) => { const scopeId = nextScopeId(); - write(`${markHydrateNode(scopeId, 0)}`); + write(`${markHydrateNode(scopeId, 0)}`); // eslint-disable-next-line no-sparse-arrays writeHydrateScope(scopeId, { 7: onClick }); diff --git a/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/components/display-intersection.js b/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/components/display-intersection.js index 81579bf9b..4a5d7f29b 100644 --- a/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/components/display-intersection.js +++ b/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/components/display-intersection.js @@ -1,10 +1,10 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ value }, _tagVar) => { const _scope = _nextScopeId(); const dummy = {}; - _write(`
    ${_markHydrateNode(_scope, 0)}${_escapeXML((dummy, value))}
    `); + _write(`
    ${_escapeXML((dummy, value))}${_markHydrateNode(_scope, 0)}
    `); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/template.js index a4004bd37..4c3ce98c2 100644 --- a/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/html.expected/template.js @@ -9,7 +9,7 @@ const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); } }); - _write(`${_markHydrateNode(_scope, 0)}`); + _write(`${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/component-attrs-intersection/template.marko_0_count"); _writeHydrateScope(_scope, { 1: count diff --git a/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/ssr.expected.md index 72d8ebe85..451f2163d 100644 --- a/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/component-attrs-intersection/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    0
    +
    0
    # Render "End" @@ -8,11 +8,11 @@
    - 0 +
    -
    `); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-derivation/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/context-tag-derivation/__snapshots__/ssr.expected.md index 32eeb9be7..48fd54c8d 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-derivation/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/context-tag-derivation/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    123
    +
    123
    # Render "End" @@ -8,8 +8,8 @@
    - 123 +
    @@ -21,6 +21,6 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 -inserted #document/html0/body1/div0/#comment0 -inserted #document/html0/body1/div0/#text1 +inserted #document/html0/body1/div0/#text0 +inserted #document/html0/body1/div0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/html.expected/template.js index 03e007b05..371bd0729 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/html.expected/template.js @@ -1,11 +1,11 @@ -import { write as _write, getInContext as _getInContext, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, getInContext as _getInContext, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); _write("
    "); const { x } = _getInContext("$"); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(x)}
    `); + _write(`${_escapeXML(x)}${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/ssr.expected.md index f4c0eae19..7398efd3d 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-global/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    1
    +
    1
    # Render "End" @@ -9,8 +9,8 @@
    - 1 +
    @@ -24,6 +24,6 @@ inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/span0 -inserted #document/html0/body1/div0/span0/#comment0 -inserted #document/html0/body1/div0/span0/#text1 +inserted #document/html0/body1/div0/span0/#text0 +inserted #document/html0/body1/div0/span0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/other.js b/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/other.js index 26143b5d7..7b8063056 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/other.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/other.js @@ -1,7 +1,7 @@ -import { markHydrateNode as _markHydrateNode, write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); + _write(""); _dynamicTag(input.renderBody, null); _write(""); }; diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/template.js index 122055faa..947565bf0 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected/template.js @@ -1,5 +1,5 @@ import Other from "./other.marko"; -import { write as _write, getInContext as _getInContext, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, getInContext as _getInContext, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); Other({ @@ -7,7 +7,7 @@ const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); _write(""); const message = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/other.marko"); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(message)}`); + _write(`${_escapeXML(message)}${_markHydrateNode(_scope, 0)}`); } }); }; diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected/template.js index c8e25e1da..db9aa0d12 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected/template.js @@ -1,11 +1,11 @@ -import { write as _write, pushContext as _pushContext, getInContext as _getInContext, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, popContext as _popContext, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, pushContext as _pushContext, getInContext as _getInContext, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, popContext as _popContext, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); _write("
    "); _pushContext("packages/translator/src/__tests__/fixtures/context-tag-from-self/template.marko", 1); _write(""); const x = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-from-self/template.marko"); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(x)}`); + _write(`${_escapeXML(x)}${_markHydrateNode(_scope, 0)}`); _popContext(); _write("
    "); }; diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/ssr.expected.md index f4c0eae19..7398efd3d 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    1
    +
    1
    # Render "End" @@ -9,8 +9,8 @@
    - 1 +
    @@ -24,6 +24,6 @@ inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/span0 -inserted #document/html0/body1/div0/span0/#comment0 -inserted #document/html0/body1/div0/span0/#text1 +inserted #document/html0/body1/div0/span0/#text0 +inserted #document/html0/body1/div0/span0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/components/other.js b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/components/other.js index 2fdb31fc7..1a6067094 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/components/other.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/components/other.js @@ -1,8 +1,7 @@ -import { pushContext as _pushContext, markHydrateNode as _markHydrateNode, write as _write, dynamicTag as _dynamicTag, popContext as _popContext, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { pushContext as _pushContext, dynamicTag as _dynamicTag, popContext as _popContext, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); _pushContext("packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/components/other.marko", "Hello"); - _write(`${_markHydrateNode(_scope, 0)}`); _dynamicTag(input.renderBody, null); _popContext(); }; diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/template.js index b9c4ce66a..dd0a3075d 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { write as _write, getInContext as _getInContext, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, getInContext as _getInContext, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _other from "./components/other.marko"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); @@ -7,7 +7,7 @@ const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); _write(""); const message = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/components/other.marko"); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(message)}`); + _write(`${_escapeXML(message)}${_markHydrateNode(_scope, 0)}`); } }); }; diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/ssr.expected.md index 24cd1195d..2b1f39f28 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/ssr.expected.md @@ -1,16 +1,15 @@ # Write - Hello + Hello # Render "End" ```html - - Hello + @@ -18,11 +17,10 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/span0 -inserted #document/html1/body1/span0/#comment0 -inserted #document/html1/body1/span0/#text1 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/span0 +inserted #document/html0/body1/span0/#text0 +inserted #document/html0/body1/span0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/html.expected/template.js index e2f61ff46..642ef274d 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/html.expected/template.js @@ -1,18 +1,17 @@ -import { write as _write, pushContext as _pushContext, markHydrateNode as _markHydrateNode, getInContext as _getInContext, escapeXML as _escapeXML, nextScopeId as _nextScopeId, popContext as _popContext, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, pushContext as _pushContext, getInContext as _getInContext, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, popContext as _popContext, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const show = true; _write("
    "); _pushContext("packages/translator/src/__tests__/fixtures/context-tag-in-if/template.marko", 123); - _write(`${_markHydrateNode(_scope, 0)}`); if (show) { const _scope = _nextScopeId(); _write(""); const x = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-in-if/template.marko"); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(x)}`); + _write(`${_escapeXML(x)}${_markHydrateNode(_scope, 0)}`); } _popContext(); - _write(`${_markHydrateNode(_scope, 2)}
    `); + _write(`${_markHydrateNode(_scope, 2)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/context-tag-in-if/template.marko_0_show"); _writeHydrateScope(_scope, { 3: show diff --git a/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/ssr.expected.md index bac4683f3..89f296722 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/context-tag-in-if/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    123
    +
    123
    # Render "End" @@ -8,17 +8,16 @@
    - - 123 + - +
    +
    123
    # Render "End" @@ -8,16 +8,16 @@
    - 123 +
    - + @@ -31,12 +31,12 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 -inserted #document/html0/body1/div0/#comment0 -inserted #document/html0/body1/div0/#text1 -inserted #document/html0/body1/#comment1 -inserted #document/html0/body1/button2 -inserted #document/html0/body1/button2/#comment0 -inserted #document/html0/body1/button2/#text1 +inserted #document/html0/body1/div0/#text0 +inserted #document/html0/body1/div0/#comment1 +inserted #document/html0/body1/button1 +inserted #document/html0/body1/button1/#text0 +inserted #document/html0/body1/button1/#comment1 +inserted #document/html0/body1/#comment2 inserted #document/html0/body1/script3 inserted #document/html0/body1/script3/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/html.expected/components/child.js b/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/html.expected/components/child.js index 879835c1e..e9c6f03e8 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/html.expected/components/child.js +++ b/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/html.expected/components/child.js @@ -1,9 +1,9 @@ -import { write as _write, getInContext as _getInContext, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, getInContext as _getInContext, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); _write("
    "); const x = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-static/template.marko"); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(x)}
    `); + _write(`${_escapeXML(x)}${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/ssr.expected.md index 32eeb9be7..48fd54c8d 100644 --- a/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/context-tag-static/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    123
    +
    123
    # Render "End" @@ -8,8 +8,8 @@
    - 123 +
    @@ -21,6 +21,6 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 -inserted #document/html0/body1/div0/#comment0 -inserted #document/html0/body1/div0/#text1 +inserted #document/html0/body1/div0/#text0 +inserted #document/html0/body1/div0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/template.js index 923849217..3d20b5a71 100644 --- a/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _customTag from "./components/custom-tag.marko"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); @@ -7,7 +7,7 @@ const _renderer = (input, _tagVar) => { c }) { const _scope = _nextScopeId(); - _write(`
    ${_markHydrateNode(_scope, 0)}${_escapeXML(a)} ${_markHydrateNode(_scope, 1)}${_escapeXML(b)} ${_markHydrateNode(_scope, 2)}${_escapeXML(c)}
    `); + _write(`
    ${_escapeXML(a)}${_markHydrateNode(_scope, 0)} ${_escapeXML(b)}${_markHydrateNode(_scope, 1)} ${_escapeXML(c)}${_markHydrateNode(_scope, 2)}
    `); } }); }; diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected/components/child/index.js b/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected/components/child/index.js index b93806f41..a5f75c47c 100644 --- a/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected/components/child/index.js +++ b/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected/components/child/index.js @@ -1,7 +1,6 @@ -import { markHydrateNode as _markHydrateNode, write as _write, dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); _dynamicTag(input.renderBody, null); }; export default _renderer; diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected/hello.js b/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected/hello.js index 7efa9baeb..816738d5a 100644 --- a/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected/hello.js +++ b/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected/hello.js @@ -1,7 +1,7 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`Hello ${_markHydrateNode(_scope, 0)}${_escapeXML(input.name)}!`); + _write(`Hello ${_escapeXML(input.name)}${_markHydrateNode(_scope, 0)}!`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/html.expected/template.js index c2b6c4f84..4f4c9dfe6 100644 --- a/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/html.expected/template.js @@ -1,4 +1,4 @@ -import { nextScopeId as _nextScopeId, register as _register, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { nextScopeId as _nextScopeId, register as _register, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; import _child from "./components/child.marko"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); @@ -7,7 +7,7 @@ const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); } }, _register(() => {}, "packages/translator/src/__tests__/fixtures/custom-tag-var-expression/template.marko_0_data", _scope)); - _write(`
    ${_markHydrateNode(_scope, 0)}${_escapeXML(data)}
    `); + _write(`
    ${_escapeXML(data)}${_markHydrateNode(_scope, 0)}
    `); _writeHydrateScope(_scope, {}); }; export default _renderer; diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/hydrate.expected.md index a383f9ba6..7b55c68f8 100644 --- a/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/custom-tag-var-expression/__snapshots__/hydrate.expected.md @@ -7,8 +7,8 @@ child
    - 4 +
    + child
    4
    # Render "End" @@ -11,8 +11,8 @@ child
    - 4 +
    + child
    3
    # Render "End" @@ -11,8 +11,8 @@ child
    - 3 +
    +
    1
    # Render "End" ```html - +
    - 1 +
    +
    # Render "End" @@ -8,12 +8,12 @@
    - +
    + 10 # Render "End" @@ -8,12 +8,12 @@ - 1 + - 0 + @@ -27,16 +27,16 @@ container.querySelector("button").click(); ```html - - + 2 + @@ -46,8 +46,8 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/#text2: "1" => "2" -#document/html1/body1/button0/#text1: "1" => "2" +#document/html0/body1/#text2: "1" => "2" +#document/html0/body1/button0/#text0: "1" => "2" ``` @@ -55,16 +55,16 @@ container.querySelector("button").click(); container.querySelector("button").click(); ```html - - + 4 + @@ -74,8 +74,8 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/#text2: "2" => "4" -#document/html1/body1/button0/#text1: "2" => "4" +#document/html0/body1/#text2: "2" => "4" +#document/html0/body1/button0/#text0: "2" => "4" ``` @@ -83,16 +83,16 @@ container.querySelector("button").click(); container.querySelector("button").click(); ```html - - + 8 + @@ -102,6 +102,6 @@ container.querySelector("button").click(); # Mutations ``` -#document/html1/body1/#text2: "4" => "8" -#document/html1/body1/button0/#text1: "4" => "8" +#document/html0/body1/#text2: "4" => "8" +#document/html0/body1/button0/#text0: "4" => "8" ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/ssr.expected.md index 52caa0155..4e123200a 100644 --- a/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/ssr.expected.md @@ -1,19 +1,19 @@ # Write - 1 + 1 # Render "End" ```html - - + 1 + @@ -23,15 +23,15 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/button0 -inserted #document/html1/body1/button0/#comment0 -inserted #document/html1/body1/button0/#text1 -inserted #document/html1/body1/#comment1 -inserted #document/html1/body1/#text2 -inserted #document/html1/body1/script3 -inserted #document/html1/body1/script3/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/button0 +inserted #document/html0/body1/button0/#text0 +inserted #document/html0/body1/button0/#comment1 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/#text2 +inserted #document/html0/body1/#comment3 +inserted #document/html0/body1/script4 +inserted #document/html0/body1/script4/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/html.expected/template.js index c2d54c1bd..7a331c9ae 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/html.expected/template.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const x = 0; const prev = false; - _write(`
    x=${_markHydrateNode(_scope, 0)}${_escapeXML(x)}, was=${_markHydrateNode(_scope, 1)}${_escapeXML(prev)}
    ${_markHydrateNode(_scope, 2)}`); + _write(`
    x=${_escapeXML(x)}${_markHydrateNode(_scope, 0)}, was=${_escapeXML(prev)}${_markHydrateNode(_scope, 1)}
    ${_markHydrateNode(_scope, 2)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/template.marko_0_x"); _writeHydrateScope(_scope, { 3: x diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/hydrate.expected.md index e0c1f1cfd..678b796cf 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/hydrate.expected.md @@ -6,19 +6,20 @@
    x= - 0 + , was= - + false +
    - + @@ -42,19 +43,20 @@ container.querySelector("#increment")?.click();
    x= - 1 + , was= - + 0 +
    - + @@ -64,7 +66,7 @@ container.querySelector("#increment")?.click(); # Mutations ``` -#document/html0/body1/div0/span1/#text1: "0" => "1" +#document/html0/body1/div0/span1/#text0: "0" => "1" #document/html0/body1/div0/#text4: "false" => "0" ``` @@ -79,19 +81,20 @@ container.querySelector("#increment")?.click();
    x= - 2 + , was= - + 0 +
    - + @@ -101,7 +104,7 @@ container.querySelector("#increment")?.click(); # Mutations ``` -#document/html0/body1/div0/span1/#text1: "1" => "2" +#document/html0/body1/div0/span1/#text0: "1" => "2" ``` @@ -113,19 +116,20 @@ container.querySelector("#increment")?.click();
    x= - 2 + , was= - + 1 +
    - + diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/ssr.expected.md index cad12ad44..45de9d06d 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag-assignment/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    x=0, was=false
    +
    x=0, was=false
    # Render "End" @@ -10,19 +10,20 @@
    x= - 0 + , was= - + false +
    - + @@ -38,14 +39,15 @@ inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/#text0 inserted #document/html0/body1/div0/span1 -inserted #document/html0/body1/div0/span1/#comment0 -inserted #document/html0/body1/div0/span1/#text1 +inserted #document/html0/body1/div0/span1/#text0 +inserted #document/html0/body1/div0/span1/#comment1 inserted #document/html0/body1/div0/#text2 inserted #document/html0/body1/div0/#comment3 inserted #document/html0/body1/div0/#text4 -inserted #document/html0/body1/#comment1 -inserted #document/html0/body1/button2 -inserted #document/html0/body1/button2/#text0 +inserted #document/html0/body1/div0/#comment5 +inserted #document/html0/body1/button1 +inserted #document/html0/body1/button1/#text0 +inserted #document/html0/body1/#comment2 inserted #document/html0/body1/script3 inserted #document/html0/body1/script3/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag-conditional/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/lifecycle-tag-conditional/__snapshots__/html.expected/template.js index 597f01ad9..a85bb76f3 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag-conditional/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag-conditional/__snapshots__/html.expected/template.js @@ -1,9 +1,8 @@ -import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, markHydrateNode as _markHydrateNode, write as _write, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const x = 0; const show = true; - _write(`${_markHydrateNode(_scope, 0)}`); if (show) { const _scope = _nextScopeId(); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/lifecycle-tag-conditional/template.marko_1_x"); @@ -11,7 +10,7 @@ const _renderer = (input, _tagVar) => { 8: x }); } - _write(`
    ${_markHydrateNode(_scope, 6)}${_markHydrateNode(_scope, 7)}`); + _write(`
    ${_markHydrateNode(_scope, 6)}${_markHydrateNode(_scope, 7)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/lifecycle-tag-conditional/template.marko_0_show"); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/lifecycle-tag-conditional/template.marko_0_x"); _writeHydrateScope(_scope, { diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/html.expected/template.js index 786e08dce..dbb30975b 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/html.expected/template.js @@ -2,7 +2,7 @@ import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _n const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const x = 0; - _write(`
    ${_markHydrateNode(_scope, 0)}`); + _write(`
    ${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/lifecycle-tag-this/template.marko_0_x"); _writeHydrateScope(_scope, { 1: x diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/hydrate.expected.md index 40c33c824..f3f339e85 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/hydrate.expected.md @@ -8,12 +8,12 @@ > x=0, was=undefined - + @@ -39,12 +39,12 @@ container.querySelector("#increment")?.click(); > x=1, was=0 - + @@ -71,12 +71,12 @@ container.querySelector("#increment")?.click(); > x=2, was=1 - + diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/ssr.expected.md index a8e925436..1a85997bd 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag-this/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    +
    # Render "End" @@ -10,12 +10,12 @@
    - + @@ -29,9 +29,9 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 -inserted #document/html0/body1/#comment1 -inserted #document/html0/body1/button2 -inserted #document/html0/body1/button2/#text0 +inserted #document/html0/body1/button1 +inserted #document/html0/body1/button1/#text0 +inserted #document/html0/body1/#comment2 inserted #document/html0/body1/script3 inserted #document/html0/body1/script3/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/html.expected/template.js index 26376ec09..a2be0a54f 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/html.expected/template.js @@ -2,7 +2,7 @@ import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _n const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const x = 0; - _write(`
    ${_markHydrateNode(_scope, 0)}`); + _write(`
    ${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/lifecycle-tag/template.marko_0_x"); _writeHydrateScope(_scope, { 1: x diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/hydrate.expected.md index 815f0418d..6bb70fba6 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/hydrate.expected.md @@ -8,12 +8,12 @@ > Mount 0
    - + @@ -39,12 +39,12 @@ container.querySelector("#increment")?.click(); > Update 1 - + @@ -71,12 +71,12 @@ container.querySelector("#increment")?.click(); > Update 2 - + diff --git a/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/ssr.expected.md index 1209bdc75..3a6c3e398 100644 --- a/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/lifecycle-tag/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    +
    # Render "End" @@ -10,12 +10,12 @@
    - + @@ -29,9 +29,9 @@ inserted #document/html0 inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 -inserted #document/html0/body1/#comment1 -inserted #document/html0/body1/button2 -inserted #document/html0/body1/button2/#text0 +inserted #document/html0/body1/button1 +inserted #document/html0/body1/button1/#text0 +inserted #document/html0/body1/#comment2 inserted #document/html0/body1/script3 inserted #document/html0/body1/script3/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/html.expected/template.js index 96587361a..bbaba23c9 100644 --- a/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/html.expected/template.js @@ -1,7 +1,7 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`
    ${_markHydrateNode(_scope, 0)}${_escapeXML(input.x)}
    `); + _write(`
    ${_escapeXML(input.x)}${_markHydrateNode(_scope, 0)}
    `); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/hydrate.expected.md index 2c829a673..f2ec0831f 100644 --- a/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/hydrate.expected.md @@ -5,8 +5,8 @@
    - 1 +
    diff --git a/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/ssr.expected.md index f4c0eae19..7398efd3d 100644 --- a/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/migrate-input/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    1
    +
    1
    # Render "End" @@ -9,8 +9,8 @@
    - 1 +
    @@ -24,6 +24,6 @@ inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/span0 -inserted #document/html0/body1/div0/span0/#comment0 -inserted #document/html0/body1/div0/span0/#text1 +inserted #document/html0/body1/div0/span0/#text0 +inserted #document/html0/body1/div0/span0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/html.expected/template.js index c982692e5..e235745ac 100644 --- a/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/html.expected/template.js @@ -1,8 +1,8 @@ -import { getInContext as _getInContext, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { getInContext as _getInContext, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const _$global = _getInContext("$"); - _write(`
    ${_markHydrateNode(_scope, 0)}${_escapeXML(_$global.x)}
    `); + _write(`
    ${_escapeXML(_$global.x)}${_markHydrateNode(_scope, 0)}
    `); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/ssr.expected.md index f4c0eae19..7398efd3d 100644 --- a/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/migrate-out-global/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
    1
    +
    1
    # Render "End" @@ -9,8 +9,8 @@
    - 1 +
    @@ -24,6 +24,6 @@ inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/span0 -inserted #document/html0/body1/div0/span0/#comment0 -inserted #document/html0/body1/div0/span0/#text1 +inserted #document/html0/body1/div0/span0/#text0 +inserted #document/html0/body1/div0/span0/#comment1 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.expected/template.js index e1c02fa93..6fb9b11fa 100644 --- a/packages/translator/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/move-and-clear-children/__snapshots__/html.expected/template.js @@ -1,15 +1,15 @@ -import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ children }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}
    `); + _write("
    "); for (const child of children) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(child.text)}`); + _write(`${_escapeXML(child.text)}${_markHydrateNode(_scope, 0)}`); _maybeFlush(); } - _write("
    "); + _write(`
    ${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.expected/template.js index 10ab2abce..a53b2ec16 100644 --- a/packages/translator/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/move-and-clear-top-level/__snapshots__/html.expected/template.js @@ -1,10 +1,9 @@ -import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); for (const child of input.children) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(child.text)}`); + _write(`${_escapeXML(child.text)}${_markHydrateNode(_scope, 0)}`); _maybeFlush(); } }; diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/html.expected/template.js index 2caf520f6..7eb65267e 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/html.expected/template.js @@ -4,7 +4,7 @@ const _renderer = (input, _tagVar) => { const el = () => { throw new Error("Cannot reference DOM node from server"); }; - _write(`${_markHydrateNode(_scope, 0)}
    ${_markHydrateNode(_scope, 1)}`); + _write(`
    ${_markHydrateNode(_scope, 0)}`); if (true) { const _scope = _nextScopeId(); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/template.marko_1"); diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/ssr.expected.md index acf39cf94..2160e3104 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-downstream-effect/__snapshots__/ssr.expected.md @@ -1,15 +1,14 @@ # Write -
    +
    # Render "End" ```html -
    - + @@ -19,12 +18,11 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/div0 -inserted #document/html1/body1/#comment1 -inserted #document/html1/body1/script2 -inserted #document/html1/body1/script2/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/div0 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/html.expected/template.js index d13550ab5..691826fd4 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/html.expected/template.js @@ -5,7 +5,7 @@ const _renderer = (input, _tagVar) => { const el = () => { throw new Error("Cannot reference DOM node from server"); }; - _write(`${_markHydrateNode(_scope, 0)}
    `); + _write(`
    ${_markHydrateNode(_scope, 0)}`); _helloSetter({ el: el, renderBody() { diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/ssr.expected.md index 240d81d68..e8cf863d4 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect-child/__snapshots__/ssr.expected.md @@ -1,14 +1,14 @@ # Write -
    +
    # Render "End" ```html -
    + @@ -18,11 +18,11 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/div0 -inserted #document/html1/body1/script1 -inserted #document/html1/body1/script1/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/div0 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/html.expected/template.js index 6f5b89961..ebf6c28cb 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/html.expected/template.js @@ -4,7 +4,7 @@ const _renderer = (input, _tagVar) => { const el = () => { throw new Error("Cannot reference DOM node from server"); }; - _write(`${_markHydrateNode(_scope, 0)}
    `); + _write(`
    ${_markHydrateNode(_scope, 0)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/native-tag-ref-effect/template.marko_0"); }; export default _renderer; diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/ssr.expected.md index 938902046..5f283ba16 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-effect/__snapshots__/ssr.expected.md @@ -1,14 +1,14 @@ # Write -
    +
    # Render "End" ```html -
    + @@ -18,11 +18,11 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/div0 -inserted #document/html1/body1/script1 -inserted #document/html1/body1/script1/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/div0 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/html.expected/template.js index e145e8a19..d0d23b328 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/html.expected/template.js @@ -1,13 +1,12 @@ import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); if (true) { const _scope = _nextScopeId(); const el = () => { throw new Error("Cannot reference DOM node from server"); }; - _write(`${_markHydrateNode(_scope, 0)}
    `); + _write(`
    ${_markHydrateNode(_scope, 0)}`); } _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/template.marko_0"); }; diff --git a/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/ssr.expected.md index 74c5fd516..e1ca01d40 100644 --- a/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/native-tag-ref-hoisting/__snapshots__/ssr.expected.md @@ -1,15 +1,14 @@ # Write -
    +
    # Render "End" ```html - -
    + @@ -19,12 +18,11 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/#comment1 -inserted #document/html2 -inserted #document/html2/head0 -inserted #document/html2/body1 -inserted #document/html2/body1/div0 -inserted #document/html2/body1/script1 -inserted #document/html2/body1/script1/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/div0 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/script2 +inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/html.expected/template.js index 2805ab836..a20ea3a1d 100644 --- a/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/html.expected/template.js @@ -1,10 +1,10 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const clickCount = 0; const lastCount = 0; const lastCount2 = 0; - _write(`${_markHydrateNode(_scope, 0)}used to be ${_markHydrateNode(_scope, 2)}${_escapeXML(lastCount)} which should be the same as ${_markHydrateNode(_scope, 3)}${_escapeXML(lastCount2)}`); + _write(`${_markHydrateNode(_scope, 0)}used to be ${_escapeXML(lastCount)}${_markHydrateNode(_scope, 2)} which should be the same as ${_escapeXML(lastCount2)}${_markHydrateNode(_scope, 3)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/nested-assignment-expression/template.marko_0_clickCount"); _writeHydrateScope(_scope, { 4: clickCount diff --git a/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/hydrate.expected.md index 645bc2c26..274136f2a 100644 --- a/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/nested-assignment-expression/__snapshots__/hydrate.expected.md @@ -1,22 +1,22 @@ # Render {} ```html - + used to be - 0 + which should be the same as - 0 + + used to be 0 which should be the same as 0 # Render "End" ```html - + used to be - 0 + which should be the same as - 0 +
    `); }; export default _renderer; diff --git a/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/html.expected/template.js index 82df5795b..680023162 100644 --- a/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/html.expected/template.js @@ -1,8 +1,8 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const count = 0; - _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 2)}${_markHydrateNode(_scope, 4)}`); + _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 2)}${_markHydrateNode(_scope, 4)}`); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/reassignment-expression-counter/template.marko_0_count"); _writeHydrateScope(_scope, { 6: count diff --git a/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/hydrate.expected.md index 680fb586e..ee0e739a4 100644 --- a/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/hydrate.expected.md @@ -1,29 +1,29 @@ # Render {} ```html - - + - + + @@ -41,30 +41,30 @@ container.querySelector("#addTwo").click(); ```html - - + - + + @@ -74,9 +74,9 @@ container.querySelector("#addTwo").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "0" => "2" -#document/html1/body1/button2/#text1: "0" => "2" -#document/html1/body1/button4/#text1: "0" => "2" +#document/html0/body1/button0/#text0: "0" => "2" +#document/html0/body1/button2/#text0: "0" => "2" +#document/html0/body1/button4/#text0: "0" => "2" ``` @@ -84,30 +84,30 @@ container.querySelector("#addTwo").click(); container.querySelector("#triple").click(); ```html - - + - + + @@ -117,9 +117,9 @@ container.querySelector("#triple").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "2" => "6" -#document/html1/body1/button2/#text1: "2" => "6" -#document/html1/body1/button4/#text1: "2" => "6" +#document/html0/body1/button0/#text0: "2" => "6" +#document/html0/body1/button2/#text0: "2" => "6" +#document/html0/body1/button4/#text0: "2" => "6" ``` @@ -127,30 +127,30 @@ container.querySelector("#triple").click(); container.querySelector("#cube").click(); ```html - - + - + + @@ -160,7 +160,7 @@ container.querySelector("#cube").click(); # Mutations ``` -#document/html1/body1/button0/#text1: "6" => "216" -#document/html1/body1/button2/#text1: "6" => "216" -#document/html1/body1/button4/#text1: "6" => "216" +#document/html0/body1/button0/#text0: "6" => "216" +#document/html0/body1/button2/#text0: "6" => "216" +#document/html0/body1/button4/#text0: "6" => "216" ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/ssr.expected.md index 4f1596060..541e4d026 100644 --- a/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/reassignment-expression-counter/__snapshots__/ssr.expected.md @@ -1,33 +1,33 @@ # Write - + # Render "End" ```html - - + - + + @@ -37,21 +37,21 @@ # Mutations ``` -inserted #document/#comment0 -inserted #document/html1 -inserted #document/html1/head0 -inserted #document/html1/body1 -inserted #document/html1/body1/button0 -inserted #document/html1/body1/button0/#comment0 -inserted #document/html1/body1/button0/#text1 -inserted #document/html1/body1/#comment1 -inserted #document/html1/body1/button2 -inserted #document/html1/body1/button2/#comment0 -inserted #document/html1/body1/button2/#text1 -inserted #document/html1/body1/#comment3 -inserted #document/html1/body1/button4 -inserted #document/html1/body1/button4/#comment0 -inserted #document/html1/body1/button4/#text1 -inserted #document/html1/body1/script5 -inserted #document/html1/body1/script5/#text0 +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/button0 +inserted #document/html0/body1/button0/#text0 +inserted #document/html0/body1/button0/#comment1 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/button2 +inserted #document/html0/body1/button2/#text0 +inserted #document/html0/body1/button2/#comment1 +inserted #document/html0/body1/#comment3 +inserted #document/html0/body1/button4 +inserted #document/html0/body1/button4/#text0 +inserted #document/html0/body1/button4/#comment1 +inserted #document/html0/body1/#comment5 +inserted #document/html0/body1/script6 +inserted #document/html0/body1/script6/#text0 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.expected/template.js index e1c02fa93..6fb9b11fa 100644 --- a/packages/translator/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/remove-and-add-rows/__snapshots__/html.expected/template.js @@ -1,15 +1,15 @@ -import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, maybeFlush as _maybeFlush, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ children }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}
    `); + _write("
    "); for (const child of children) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(child.text)}`); + _write(`${_escapeXML(child.text)}${_markHydrateNode(_scope, 0)}`); _maybeFlush(); } - _write("
    "); + _write(`
    ${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/style-tag-modules-default/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/style-tag-modules-default/__snapshots__/html.expected/template.js index 20d799a98..bfde1bf0b 100644 --- a/packages/translator/src/__tests__/fixtures/style-tag-modules-default/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/style-tag-modules-default/__snapshots__/html.expected/template.js @@ -1,8 +1,8 @@ import myStyles from "virtual:./template.marko.module.css \n .content {\n color: green;\n }\n"; -import { markHydrateNode as _markHydrateNode, classAttr as _classAttr, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { classAttr as _classAttr, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 1)}Hello
    `); + _write(`Hello
    ${_markHydrateNode(_scope, 1)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/style-tag-modules-destructured/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/style-tag-modules-destructured/__snapshots__/html.expected/template.js index 9e575696b..1e38b3098 100644 --- a/packages/translator/src/__tests__/fixtures/style-tag-modules-destructured/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/style-tag-modules-destructured/__snapshots__/html.expected/template.js @@ -1,11 +1,11 @@ import _style from "virtual:./template.marko.module.css \n .content {\n color: green;\n }\n"; -import { markHydrateNode as _markHydrateNode, classAttr as _classAttr, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { classAttr as _classAttr, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); const { content } = _style; - _write(`${_markHydrateNode(_scope, 1)}Hello
    `); + _write(`Hello
    ${_markHydrateNode(_scope, 1)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected/template.js index 49909280d..131399cef 100644 --- a/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected/template.js @@ -1,7 +1,7 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = (input, _tagVar) => { const _scope = _nextScopeId(); - const MyTag = input => _write(`Hello ${_markHydrateNode(_scope, 0)}${_escapeXML(input.name)}`); + const MyTag = input => _write(`Hello ${_escapeXML(input.name)}${_markHydrateNode(_scope, 0)}`); MyTag({ name: "World", renderBody() { diff --git a/packages/translator/src/__tests__/fixtures/toggle-first-child/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/toggle-first-child/__snapshots__/html.expected/template.js index ac3c56c00..c127ff67d 100644 --- a/packages/translator/src/__tests__/fixtures/toggle-first-child/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/toggle-first-child/__snapshots__/html.expected/template.js @@ -1,12 +1,12 @@ -import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { write as _write, escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ value }, _tagVar) => { const _scope = _nextScopeId(); - _write(`
    ${_markHydrateNode(_scope, 0)}`); + _write("
    "); if (value) { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(value)}`); + _write(`${_escapeXML(value)}${_markHydrateNode(_scope, 0)}`); } _write("
    "); }; diff --git a/packages/translator/src/__tests__/fixtures/update-attr/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/update-attr/__snapshots__/html.expected/template.js index ae1e65c0a..d7e652529 100644 --- a/packages/translator/src/__tests__/fixtures/update-attr/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/update-attr/__snapshots__/html.expected/template.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, attr as _attr, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { attr as _attr, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ value }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}
    `); + _write(`
    ${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/html.expected/template.js index 2b1df1c25..4ea423151 100644 --- a/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/html.expected/template.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, toString as _toString, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { toString as _toString, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ value }, _tagVar) => { const _scope = _nextScopeId(); - _write(`Testing ${_markHydrateNode(_scope, 0)}${_toString(value)}`); + _write(`Testing ${_toString(value)}${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/hydrate.expected.md index 849f57734..36bedd9f6 100644 --- a/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/hydrate.expected.md @@ -7,11 +7,12 @@ Testing - + Hello World + ``` diff --git a/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/ssr.expected.md index b1e9468ba..3d0e56f88 100644 --- a/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/update-html/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write - Testing Hello World + Testing Hello World # Render "End" @@ -11,11 +11,12 @@ Testing - + Hello World + ``` @@ -32,4 +33,5 @@ inserted #document/html0/body1/#comment2 inserted #document/html0/body1/#text3 inserted #document/html0/body1/strong4 inserted #document/html0/body1/strong4/#text0 +inserted #document/html0/body1/#comment5 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/html.expected/template.js index 5b3e9e415..5996b63c7 100644 --- a/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/html.expected/template.js @@ -1,9 +1,9 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ value }, _tagVar) => { const _scope = _nextScopeId(); - _write(`Static ${_markHydrateNode(_scope, 0)}${_escapeXML(value)}`); + _write(`Static ${_escapeXML(value)}${_markHydrateNode(_scope, 0)}`); }; export default _renderer; export const render = /* @__PURE__ */_createRenderer(_renderer); \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/hydrate.expected.md b/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/hydrate.expected.md index 7351c09f0..635fba591 100644 --- a/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/hydrate.expected.md +++ b/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/hydrate.expected.md @@ -4,8 +4,9 @@ Static - + Dynamic 1 + ``` diff --git a/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/ssr.expected.md index 01720b2a4..992d10247 100644 --- a/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/ssr.expected.md +++ b/packages/translator/src/__tests__/fixtures/update-text/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write - Static Dynamic 1 + Static Dynamic 1 # Render "End" @@ -8,8 +8,9 @@ Static - + Dynamic 1 + ``` @@ -22,4 +23,5 @@ inserted #document/html0/body1 inserted #document/html0/body1/#text0 inserted #document/html0/body1/#comment1 inserted #document/html0/body1/#text2 +inserted #document/html0/body1/#comment3 ``` \ No newline at end of file diff --git a/packages/translator/src/__tests__/fixtures/user-effect-cleanup/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/user-effect-cleanup/__snapshots__/html.expected/template.js index 522aff05c..35d815c19 100644 --- a/packages/translator/src/__tests__/fixtures/user-effect-cleanup/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/user-effect-cleanup/__snapshots__/html.expected/template.js @@ -1,11 +1,11 @@ -import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { escapeXML as _escapeXML, markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ value }, _tagVar) => { const _scope = _nextScopeId(); const a = 0; const b = 0; - _write(`
    ${_markHydrateNode(_scope, 0)}${_escapeXML("" + a + b)}
    `); + _write(`
    ${_escapeXML("" + a + b)}${_markHydrateNode(_scope, 0)}
    `); _writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/user-effect-cleanup/template.marko_0_value"); _writeHydrateScope(_scope, { 1: value diff --git a/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected/template.js b/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected/template.js index 32b597b69..39a839537 100644 --- a/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected/template.js +++ b/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected/template.js @@ -1,9 +1,8 @@ -import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; +import { nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html"; const _renderer = ({ show }, _tagVar) => { const _scope = _nextScopeId(); - _write(`${_markHydrateNode(_scope, 0)}`); if (show) { const _scope = _nextScopeId(); const _return = 1; diff --git a/packages/translator/src/util/walks.ts b/packages/translator/src/util/walks.ts index df2177852..a0b35a286 100644 --- a/packages/translator/src/util/walks.ts +++ b/packages/translator/src/util/walks.ts @@ -2,12 +2,10 @@ import { types as t } from "@marko/compiler"; import { createSectionState, getSectionId } from "../util/sections"; import { ReserveType } from "../util/reserve"; import { isOutputHTML } from "./marko-config"; -import { callRuntime } from "./runtime"; import toTemplateOrStringLiteral, { appendLiteral, } from "./to-template-string-or-literal"; import { writeTo } from "./writer"; -import { scopeIdentifier } from "../visitors/program"; const [getWalks] = createSectionState<(string | t.Expression)[]>( "walks", @@ -127,77 +125,73 @@ export function visit( ); } + if (isOutputHTML()) { + return; + } + const sectionId = getSectionId(path); const steps = getSteps(sectionId); const walks = getWalks(sectionId); const walkComment = getWalkComment(sectionId); - if (code && isOutputHTML()) { - writeTo(path)`${callRuntime( - "markHydrateNode", - scopeIdentifier, - t.numericLiteral(reserve!.id) - )}`; - } else { - let walkString = ""; + let walkString = ""; - if (steps.length) { - const walks: WalkCodes[] = []; - let depth = 0; + if (steps.length) { + const walks: WalkCodes[] = []; + let depth = 0; - for (const step of steps) { - if (step === Step.enter) { - depth++; - walks.push(WalkCodes.Next); + for (const step of steps) { + if (step === Step.enter) { + depth++; + walks.push(WalkCodes.Next); + } else { + depth--; + if (depth >= 0) { + // delete back to and including previous NEXT + walks.length = walks.lastIndexOf(WalkCodes.Next); + walks.push(WalkCodes.Over); } else { - depth--; - if (depth >= 0) { - // delete back to and including previous NEXT - walks.length = walks.lastIndexOf(WalkCodes.Next); - walks.push(WalkCodes.Over); - } else { - // delete back to previous OUT - walks.length = walks.lastIndexOf(WalkCodes.Out) + 1; - walks.push(WalkCodes.Out); - depth = 0; - } + // delete back to previous OUT + walks.length = walks.lastIndexOf(WalkCodes.Out) + 1; + walks.push(WalkCodes.Out); + depth = 0; } } + } - let current = walks[0]; - let count = 0; + let current = walks[0]; + let count = 0; - for (const walk of walks) { - if (walk !== current) { - walkComment.push(`${walkCodeToName[current]}(${count})`); - walkString += nCodeString(current, count); - current = walk; - count = 1; - } else { - count++; - } + for (const walk of walks) { + if (walk !== current) { + walkComment.push(`${walkCodeToName[current]}(${count})`); + walkString += nCodeString(current, count); + current = walk; + count = 1; + } else { + count++; } - - walkComment.push(`${walkCodeToName[current]}(${count})`); - walkString += nCodeString(current, count); - steps.length = 0; } - if (code !== undefined) { - if (code !== WalkCodes.Get) { - writeTo(path)``; - } - walkComment.push(`${walkCodeToName[code]}`); - walkString += String.fromCharCode(code); - } - - if (reserve?.size) { - walkComment.push(`${walkCodeToName[WalkCodes.Skip]}(${reserve.size})`); - walkString += nCodeString(WalkCodes.Skip, reserve.size); - } - - appendLiteral(walks, walkString); + walkComment.push(`${walkCodeToName[current]}(${count})`); + walkString += nCodeString(current, count); + steps.length = 0; } + + if (code !== undefined) { + if (code !== WalkCodes.Get) { + writeTo(path)``; + } + walkComment.push(`${walkCodeToName[code]}`); + walkString += String.fromCharCode(code); + } + + if (reserve?.size) { + walkComment.push(`${walkCodeToName[WalkCodes.Skip]}(${reserve.size})`); + walkString += nCodeString(WalkCodes.Skip, reserve.size); + } + + appendLiteral(walks, walkString); } function nCodeString(code: WalkCodes, number: number) { diff --git a/packages/translator/src/util/writer.ts b/packages/translator/src/util/writer.ts index d7d7479b4..257914914 100644 --- a/packages/translator/src/util/writer.ts +++ b/packages/translator/src/util/writer.ts @@ -6,7 +6,9 @@ import toTemplateOrStringLiteral, { } from "./to-template-string-or-literal"; import { getWalkString } from "./walks"; import { getSetup } from "./signals"; -import { currentProgramPath } from "../visitors/program"; +import { currentProgramPath, scopeIdentifier } from "../visitors/program"; +import { isOutputHTML } from "./marko-config"; +import { ReserveType } from "./reserve"; const [getRenderer] = createSectionState( "renderer", @@ -83,3 +85,21 @@ export function getSectionMeta(sectionId: number) { writes: toTemplateOrStringLiteral(writes) || t.stringLiteral(""), }; } + +export function markNode(path: t.NodePath) { + const { reserve } = path.node.extra; + + if (reserve?.type !== ReserveType.Visit) { + throw path.buildCodeFrameError( + "Tried to mark a node that was not determined to need a mark during analyze." + ); + } + + if (isOutputHTML()) { + writeTo(path)`${callRuntime( + "markHydrateNode", + scopeIdentifier, + t.numericLiteral(reserve!.id) + )}`; + } +} diff --git a/packages/translator/src/visitors/placeholder.ts b/packages/translator/src/visitors/placeholder.ts index 58c5f7ab7..39f52fd20 100644 --- a/packages/translator/src/visitors/placeholder.ts +++ b/packages/translator/src/visitors/placeholder.ts @@ -64,6 +64,7 @@ export default { method as HTMLMethod | DOMMethod, placeholder.node.value )}`; + writer.markNode(placeholder); } else { addStatement( "apply", diff --git a/packages/translator/src/visitors/tag/native-tag.ts b/packages/translator/src/visitors/tag/native-tag.ts index 684635ce9..0b137abbc 100644 --- a/packages/translator/src/visitors/tag/native-tag.ts +++ b/packages/translator/src/visitors/tag/native-tag.ts @@ -279,6 +279,10 @@ export default { .skip(); } + if (extra.reserve) { + writer.markNode(tag); + } + walks.exit(tag); tag.remove(); }, diff --git a/packages/translator/src/visitors/text.ts b/packages/translator/src/visitors/text.ts index 7f439b48e..b63e87747 100644 --- a/packages/translator/src/visitors/text.ts +++ b/packages/translator/src/visitors/text.ts @@ -1,10 +1,25 @@ -import type { types as t } from "@marko/compiler"; +import { types as t } from "@marko/compiler"; import * as writer from "../util/writer"; import * as walks from "../util/walks"; +import { isOutputHTML } from "../util/marko-config"; export default { translate(text: t.NodePath) { - writer.writeTo(text)`${text.node.value}`; + const followingSiblings = (text.container as t.Statement[]).slice( + (text.key as number) + 1 + ); + let needsSeparator = false; + if (isOutputHTML()) { + for (const sibling of followingSiblings) { + if (t.isMarkoPlaceholder(sibling)) { + needsSeparator = true; + break; + } else if (t.isMarkoTag(sibling) || t.isMarkoText(sibling)) { + break; + } + } + } + writer.writeTo(text)`${text.node.value}${needsSeparator ? "" : ""}`; walks.enterShallow(text); text.remove(); },