From c77bfd03e701ee60ebb37fb563032721bf40cfd3 Mon Sep 17 00:00:00 2001
From: Michael Rawlings
Date: Sat, 2 Apr 2022 02:55:33 -0400
Subject: [PATCH] fix: node markers have correct scope
---
.../__snapshots__/html.expected.js | 10 ++--
.../components/custom-tag/index.js | 4 +-
.../__snapshots__/html.expected.js | 10 ++--
.../html.expected/components/hello/index.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 12 ++---
.../html.expected/components/hello/index.js | 4 +-
.../__snapshots__/html.expected.js | 19 +++----
.../html.expected/components/hello/index.js | 4 +-
.../at-tags/__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../attr-class/__snapshots__/html.expected.js | 6 +--
.../html.expected/components/custom-tag.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../attr-style/__snapshots__/html.expected.js | 6 +--
.../html.expected/components/custom-tag.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../html.expected/components/my-button.js | 6 +--
.../__snapshots__/html.expected.js | 4 +-
.../html.expected/components/counter.js | 8 +--
.../__snapshots__/html.expected.js | 8 +--
.../__snapshots__/html.expected.js | 2 +-
.../__snapshots__/ssr.expected.md | 6 +--
.../__snapshots__/html.expected.js | 10 ++--
.../__snapshots__/html.expected.js | 8 +--
.../__snapshots__/html.expected.js | 8 +--
.../__snapshots__/html.expected.js | 8 +--
.../__snapshots__/html.expected.js | 8 +--
.../__snapshots__/html.expected.js | 8 +--
.../__snapshots__/html.expected.js | 14 +++--
.../__snapshots__/html.expected.js | 10 ++--
.../__snapshots__/html.expected.js | 8 +--
.../cdata/__snapshots__/html.expected.js | 4 +-
.../comments/__snapshots__/html.expected.js | 4 +-
.../const-tag/__snapshots__/html.expected.js | 6 +--
.../__snapshots__/html.expected.js | 10 ++--
.../__snapshots__/html.expected.js | 6 +--
.../__snapshots__/html.expected.js | 10 ++--
.../html.expected/components/other.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../html.expected/components/hello/index.js | 4 +-
.../html.expected/components/message.js | 4 +-
.../__snapshots__/html.expected.js | 8 +--
.../html.expected/components/custom-tag.js | 4 +-
.../__snapshots__/html.expected.js | 8 +--
.../html.expected/components/child/index.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 6 +--
.../html.expected/components/child/index.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../doctype/__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 20 ++++----
.../__snapshots__/html.expected.js | 6 +--
.../html.expected/components/child/index.js | 4 +-
.../__snapshots__/html.expected.js | 8 +--
.../effect-tag/__snapshots__/html.expected.js | 6 +--
.../entities/__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 8 +--
.../html.expected/components/child/index.js | 4 +-
.../__snapshots__/html.expected.js | 12 ++---
.../for-tag/__snapshots__/html.expected.js | 42 +++++++--------
.../__snapshots__/html.expected.js | 4 +-
.../__snapshots__/html.expected.js | 4 +-
.../if-tag/__snapshots__/html.expected.js | 10 ++--
.../__snapshots__/html.expected.js | 4 +-
.../import-tag/__snapshots__/html.expected.js | 6 +--
.../html.expected/components/baz.js | 4 +-
.../__snapshots__/html.expected.js | 6 +--
.../let-tag/__snapshots__/html.expected.js | 8 +--
.../__snapshots__/html.expected.js | 6 +--
.../style-tag/__snapshots__/html.expected.js | 4 +-
.../tag-tag/__snapshots__/html.expected.js | 6 +--
.../yield-tag/__snapshots__/html.expected.js | 6 +--
.../translator/src/__tests__/main.test.ts | 2 +-
packages/translator/src/util/apply-hydrate.ts | 51 +++++++++++++++----
packages/translator/src/util/walks.ts | 2 +
80 files changed, 304 insertions(+), 274 deletions(-)
diff --git a/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected.js
index c8ec24631..83bbf41fa 100644
--- a/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected.js
@@ -2,9 +2,13 @@ import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _n
import _customTag from "./components/custom-tag/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
let _thing;
- _write(`${_markHydrateNode(0)}`);
+ const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}`);
if (x) _thing = {
x: 1,
@@ -15,13 +19,9 @@ const _renderer = input => {
};
- const _scope = _nextScopeId();
-
_customTag({
thing: _thing
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/components/custom-tag/index.js b/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/components/custom-tag/index.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/components/custom-tag/index.js
+++ b/packages/translator/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/components/custom-tag/index.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected.js
index d29f0dcc5..7e4eb1dce 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected.js
@@ -2,9 +2,13 @@ import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _n
import _hello from "./components/hello/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const _item = [];
- _write(`${_markHydrateNode(0)}`);
+ const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}`);
for (const a in {
a: 1,
@@ -13,14 +17,10 @@ const _renderer = input => {
_item.push({});
}
- const _scope = _nextScopeId();
-
_hello({
item: _item,
other: {}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/components/hello/index.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/components/hello/index.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/components/hello/index.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/components/hello/index.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected.js
index d2e115864..79782d3eb 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-tag-parent/__snapshots__/html.expected.js
@@ -1,6 +1,8 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
<${x} header={
class: "my-header",
@@ -18,8 +20,6 @@ const _renderer = input => {
}/>
_write("Body content");
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected.js
index 35c831872..fc5d4c777 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected.js
@@ -2,24 +2,24 @@ import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _esc
import _hello from "./components/hello/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
let _item;
- _write(`${_markHydrateNode(0)}`);
+ const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}`);
if (x) _item = {
renderBody(y) {
- _write(`${_markHydrateNode(0)}${_escapeXML(y)}`);
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(y)}`);
}
};
- const _scope = _nextScopeId();
-
_hello({
item: _item
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/components/hello/index.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/components/hello/index.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/components/hello/index.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic-with-params/__snapshots__/html.expected/components/hello/index.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected.js
index 4c3a3ffbe..b2a7579fb 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected.js
@@ -2,13 +2,18 @@ import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _esc
import _hello from "./components/hello/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const _col = [];
+
+ const _scope = _nextScopeId();
+
const _item = [];
- _write(`${_markHydrateNode(0)}`);
+ _write(`${_markHydrateNode(_scope, 0)}`);
for (const color of ["red", "blue", "green"]) {
- _write(`${_markHydrateNode(0)}`);
+ _write(`${_markHydrateNode(_scope, 0)}`);
if (color === "red") _item.push({
style: {
@@ -31,7 +36,7 @@ const _renderer = input => {
});
}
- _write(`${_markHydrateNode(0)}`);
+ _write(`${_markHydrateNode(_scope, 0)}`);
let _i = 0;
@@ -39,14 +44,14 @@ const _renderer = input => {
let i = _i++;
const _row = [];
- _write(`${_markHydrateNode(0)}`);
+ _write(`${_markHydrateNode(_scope, 0)}`);
for (const row of col) {
_row.push({
row: row,
renderBody() {
- _write(`${_markHydrateNode(0)}${_escapeXML(row)}`);
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(row)}`);
}
});
@@ -70,16 +75,12 @@ const _renderer = input => {
}
});
- const _scope = _nextScopeId();
-
_hello({
list: {
item: _item
},
col: _col
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/components/hello/index.js b/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/components/hello/index.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/components/hello/index.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags-dynamic/__snapshots__/html.expected/components/hello/index.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/at-tags/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/at-tags/__snapshots__/html.expected.js
index 7db1f84ca..9f2e133d9 100644
--- a/packages/translator/src/__tests__/fixtures/at-tags/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/at-tags/__snapshots__/html.expected.js
@@ -2,6 +2,8 @@ import { write as _write, nextScopeId as _nextScopeId, createRenderer as _create
import _hello from "./components/hello/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_hello({
foo: {
renderBody() {
@@ -15,8 +17,6 @@ const _renderer = input => {
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-boolean/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/attr-boolean/__snapshots__/html.expected.js
index 7fe93fde3..0fd6a6224 100644
--- a/packages/translator/src/__tests__/fixtures/attr-boolean/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/attr-boolean/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write(" ");
-
const _scope = _nextScopeId();
+
+ _write(" ");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected.js
index 546f12603..8f4f48a2a 100644
--- a/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected.js
@@ -2,12 +2,14 @@ import { markHydrateNode as _markHydrateNode, classAttr as _classAttr, write as
import _customTag from "./components/custom-tag.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const {
c,
d
} = input;
- _write(`${_markHydrateNode(0)}
`);
@@ -50,8 +52,6 @@ const _renderer = input => {
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/components/custom-tag.js b/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/components/custom-tag.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/components/custom-tag.js
+++ b/packages/translator/src/__tests__/fixtures/attr-class/__snapshots__/html.expected/components/custom-tag.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected.js
index f667bfa5b..001a15b84 100644
--- a/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/attr-escape/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
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";
const _renderer = input => {
- _write(`${_markHydrateNode(0)}
`);
-
const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}
`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-falsey/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/attr-falsey/__snapshots__/html.expected.js
index 675bbb468..d962d46ca 100644
--- a/packages/translator/src/__tests__/fixtures/attr-falsey/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/attr-falsey/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-scoped/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/attr-scoped/__snapshots__/html.expected.js
index a70461068..b59a00940 100644
--- a/packages/translator/src/__tests__/fixtures/attr-scoped/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/attr-scoped/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected.js
index 3bb94e61d..56284619d 100644
--- a/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected.js
@@ -2,7 +2,9 @@ import { markHydrateNode as _markHydrateNode, styleAttr as _styleAttr, write as
import _customTag from "./components/custom-tag.marko";
const _renderer = input => {
- _write(`${_markHydrateNode(0)}
`);
@@ -49,8 +51,6 @@ const _renderer = input => {
}
}/>
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/components/custom-tag.js b/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/components/custom-tag.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/components/custom-tag.js
+++ b/packages/translator/src/__tests__/fixtures/attr-style/__snapshots__/html.expected/components/custom-tag.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected.js
index 375afc0a5..835f63a6b 100644
--- a/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/attr-template-literal-escape/__snapshots__/html.expected.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";
const _renderer = input => {
- _write(`${_markHydrateNode(0)}
`);
-
const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}
`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected.js
index cfb8249a1..cf93c1fe3 100644
--- a/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/basic-component-attrs/__snapshots__/html.expected.js
@@ -2,6 +2,8 @@ import { nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "
import _myButton from "./components/my-button.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const clickCount = 0;
_myButton({
@@ -15,8 +17,6 @@ const _renderer = input => {
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
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 07d0fa7cf..ea852c1b4 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,13 +1,13 @@
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";
const _renderer = input => {
- _write(`${_markHydrateNode(0)}${_markHydrateNode(1)}${_escapeXML(text)} `);
-
const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 1)}${_escapeXML(text)} `);
+
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-component-attrs/components/my-button.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [,,, onclick]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected.js
index 82d10c73d..54faecb76 100644
--- a/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/basic-component/__snapshots__/html.expected.js
@@ -2,6 +2,8 @@ import { write as _write, nextScopeId as _nextScopeId, createRenderer as _create
import _counter from "./components/counter.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_write("");
_counter({
@@ -12,8 +14,6 @@ const _renderer = input => {
});
_write("
");
-
- const _scope = _nextScopeId();
};
export default _renderer;
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 68b69a57e..7f98f7000 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,15 +1,15 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const clickCount = 0;
- _write(`${_markHydrateNode(0)}${_markHydrateNode(1)}${_escapeXML(clickCount)} `);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 1)}${_escapeXML(clickCount)} `);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-component/components/counter.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [,, clickCount]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/html.expected.js
index 05bfa9a3a..702130d8a 100644
--- a/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/html.expected.js
@@ -1,15 +1,15 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const clickCount = 0;
- _write(`${_markHydrateNode(0)}${_markHydrateNode(1)}${_escapeXML(clickCount)}
`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 1)}${_escapeXML(clickCount)}
`);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-counter/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [,, clickCount]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/html.expected.js
index a960d8b0e..bd9e50144 100644
--- a/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/html.expected.js
@@ -5,7 +5,7 @@ const _renderer = input => {
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-effect-no-deps/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, []);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/ssr.expected.md b/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/ssr.expected.md
index ae098d395..52a7e44e9 100644
--- a/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/ssr.expected.md
+++ b/packages/translator/src/__tests__/fixtures/basic-effect-no-deps/__snapshots__/ssr.expected.md
@@ -1,5 +1,5 @@
# Write
-
+
# Render "End"
@@ -7,7 +7,7 @@
@@ -29,7 +29,7 @@ inserted html0/body1
{
+ const _scope = _nextScopeId();
+
const message = {
text: "hi"
};
const show = true;
- _write(`${_markHydrateNode(0)}${_markHydrateNode(0)}`);
+ _write(`
${_markHydrateNode(_scope, 0)}`);
- if (clickCount < 3) _write(`${_markHydrateNode(0)}${_markHydrateNode(1)}${_escapeXML(clickCount)} `);
+ if (clickCount < 3) _write(`${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 1)}${_escapeXML(clickCount)} `);
_write("
");
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected.js
index 7e99d30e3..01d4c36ff 100644
--- a/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/html.expected.js
@@ -1,26 +1,24 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const id = 0;
const items = [];
- _write(`
${_markHydrateNode(0)}`);
+ _write(`
${_markHydrateNode(_scope, 0)}`);
for (const item of items) {
- _write(`${_markHydrateNode(0)}${_escapeXML(item)}`);
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(item)}`);
}
- _write(`${_markHydrateNode(4)}Add ${_markHydrateNode(5)}Remove
`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 4)}
Add ${_markHydrateNode(_scope, 5)}
Remove `);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-push-pop-list/template.marko_0_1");
- _writeHydrateScope(_scope, {});
-
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-push-pop-list/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [,,,,,, id, items]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected.js
index 1ecb79bb7..dd1d81db7 100644
--- a/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/html.expected.js
@@ -1,19 +1,19 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const show = true;
- _write(`
${_markHydrateNode(0)}`);
+ _write(`
${_markHydrateNode(_scope, 0)}`);
if (show) _write("Hello!");
- _write(`${_markHydrateNode(4)}Toggle
`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 4)}
Toggle `);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-toggle-show/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [,,,,, show]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected.js
index f26c06049..41e586985 100644
--- a/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.expected.js
@@ -1,17 +1,17 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const unused_1 = 123;
const unused_2 = 456;
const clickCount = 0;
- _write(`
${_markHydrateNode(0)}${_markHydrateNode(1)}${_escapeXML(clickCount)}
`);
-
- const _scope = _nextScopeId();
+ _write(`
${_markHydrateNode(_scope, 0)}${_markHydrateNode(_scope, 1)}${_escapeXML(clickCount)}
`);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/basic-unused-ref/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [,,,, clickCount]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/cdata/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/cdata/__snapshots__/html.expected.js
index 19e8097dc..b00965962 100644
--- a/packages/translator/src/__tests__/fixtures/cdata/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/cdata/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
Here is a CDATA section: & ]]> with all kinds of unescaped text.
");
-
const _scope = _nextScopeId();
+
+ _write("
Here is a CDATA section: & ]]> with all kinds of unescaped text.
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/comments/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/comments/__snapshots__/html.expected.js
index f5dfbdcd8..dcc75f52c 100644
--- a/packages/translator/src/__tests__/fixtures/comments/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/comments/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/const-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/const-tag/__snapshots__/html.expected.js
index 6d8d36391..5adeca525 100644
--- a/packages/translator/src/__tests__/fixtures/const-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/const-tag/__snapshots__/html.expected.js
@@ -1,12 +1,12 @@
import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const x = 1;
const y = 1;
- _write(`
${_markHydrateNode(0)}${_escapeXML(x)}
${_markHydrateNode(1)}${_escapeXML(y)}`);
-
- const _scope = _nextScopeId();
+ _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(x)}
${_markHydrateNode(_scope, 1)}${_escapeXML(y)}`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected.js
index c9a0b58b0..0f432de10 100644
--- a/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/__snapshots__/html.expected.js
@@ -2,20 +2,20 @@ 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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
Other({
renderBody() {
+ const _scope = _nextScopeId();
+
_write("
");
const message = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-from-relative-path/other.marko");
- _write(`${_markHydrateNode(0)}${_escapeXML(message)} `);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(message)}`);
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected.js
index de6bbf2ff..3817d2283 100644
--- a/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/context-tag-from-self/__snapshots__/html.expected.js
@@ -1,6 +1,8 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_write("
");
_pushContext("packages/translator/src/__tests__/fixtures/context-tag-from-self/template.marko", 1);
@@ -9,13 +11,11 @@ const _renderer = input => {
const x = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-from-self/template.marko");
- _write(`${_markHydrateNode(0)}${_escapeXML(x)}`);
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(x)}`);
_popContext();
_write("
");
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected.js
index 3deda0867..0bc95a054 100644
--- a/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/__snapshots__/html.expected.js
@@ -2,20 +2,20 @@ import { write as _write, getInContext as _getInContext, markHydrateNode as _mar
import _other from "./components/other.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_other({
renderBody() {
+ const _scope = _nextScopeId();
+
_write("
");
const message = _getInContext("packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/components/other.marko");
- _write(`${_markHydrateNode(0)}${_escapeXML(message)} `);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(message)}`);
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
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 3554646ec..d68fec58b 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,13 +1,13 @@
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 => {
+ const _scope = _nextScopeId();
+
_pushContext("packages/translator/src/__tests__/fixtures/context-tag-from-tag-name/components/other.marko", "Hello");
_dynamicTag(input.renderBody, null);
_popContext();
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected.js
index 6adce47e6..10e4c34a8 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("Hello Frank");
-
const _scope = _nextScopeId();
+
+ _write("Hello Frank");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/hello/index.js b/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/hello/index.js
index 6d3e9041a..5f3f32257 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/hello/index.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/hello/index.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("Hello");
-
const _scope = _nextScopeId();
+
+ _write("Hello");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/message.js b/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/message.js
index 96f080cfb..f13de8b71 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/message.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-child-analyze/__snapshots__/html.expected/components/message.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("Frank");
-
const _scope = _nextScopeId();
+
+ _write("Frank");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected.js
index ce0ddcff7..cc2972306 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected.js
@@ -2,18 +2,18 @@ import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as
import _customTag from "./components/custom-tag.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_customTag({
renderBody(a, b, {
c
}) {
- _write(`
${_markHydrateNode(0)}${_escapeXML(a)} ${_markHydrateNode(1)}${_escapeXML(b)} ${_markHydrateNode(2)}${_escapeXML(c)}
`);
-
const _scope = _nextScopeId();
+
+ _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(a)} ${_markHydrateNode(_scope, 1)}${_escapeXML(b)} ${_markHydrateNode(_scope, 2)}${_escapeXML(c)}
`);
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/components/custom-tag.js b/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/components/custom-tag.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/components/custom-tag.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-parameters/__snapshots__/html.expected/components/custom-tag.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected.js
index 2d268021b..c6f181ad6 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-render-body/__snapshots__/html.expected.js
@@ -2,18 +2,18 @@ import { write as _write, nextScopeId as _nextScopeId, createRenderer as _create
import _child from "./components/child/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_child({
name: "World",
renderBody() {
- _write("This is the body content");
-
const _scope = _nextScopeId();
+
+ _write("This is the body content");
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
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 169055882..3ce7e940e 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,9 +1,9 @@
import { dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _dynamicTag(input.renderBody, null);
-
const _scope = _nextScopeId();
+
+ _dynamicTag(input.renderBody, null);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-separate-assets/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/custom-tag-separate-assets/__snapshots__/html.expected.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-separate-assets/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-separate-assets/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected.js
index fb2f5d76b..58d6f0ffd 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-template/__snapshots__/html.expected.js
@@ -2,6 +2,8 @@ import { nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "
import _hello from "./hello.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_hello({
name: "Frank",
@@ -10,8 +12,6 @@ const _renderer = input => {
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected.js
index e2addf66b..92c08a155 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected.js
@@ -2,6 +2,8 @@ import { nextScopeId as _nextScopeId, markHydrateNode as _markHydrateNode, escap
import _child from "./components/child/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const data = _child({
renderBody() {
const _scope = _nextScopeId();
@@ -9,9 +11,7 @@ const _renderer = input => {
});
- _write(`${_markHydrateNode(0)}${_escapeXML(data)}`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(data)}`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected/components/child/index.js b/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected/components/child/index.js
index cc57db7ed..2fc2a3b94 100644
--- a/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected/components/child/index.js
+++ b/packages/translator/src/__tests__/fixtures/custom-tag-var/__snapshots__/html.expected/components/child/index.js
@@ -3,10 +3,10 @@ import { nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "
const _renderer = input => {
var _return;
+ const _scope = _nextScopeId();
+
_return = 1;
return _return;
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/declaration/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/declaration/__snapshots__/html.expected.js
index 7d916f854..beb61bc68 100644
--- a/packages/translator/src/__tests__/fixtures/declaration/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/declaration/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
Hello World ");
-
const _scope = _nextScopeId();
+
+ _write("
Hello World ");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/doctype/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/doctype/__snapshots__/html.expected.js
index 979d1016f..54e7d222b 100644
--- a/packages/translator/src/__tests__/fixtures/doctype/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/doctype/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
Title of the document The content of the document......");
-
const _scope = _nextScopeId();
+
+ _write("
Title of the document The content of the document......");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/html.expected.js
index 5cfb6bbac..5f2dac40c 100644
--- a/packages/translator/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/html.expected.js
@@ -3,18 +3,20 @@ import tagB from "./components/tag-b/index.marko";
import { markHydrateNode as _markHydrateNode, attr as _attr, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
<${renderBody} class=["a", "b"] other=other/>
<${x} class=["a", "b"] other=other/>
const _tagName = show ? "div" : null;
- if (_tagName) _write(`${_markHydrateNode(0)}<${_tagName} class="a b"${_attr("other", other)}>${_tagName}>`);
+ if (_tagName) _write(`${_markHydrateNode(_scope, 0)}<${_tagName} class="a b"${_attr("other", other)}>${_tagName}>`);
const _tagName2 = show && "div";
- if (_tagName2) _write(`${_markHydrateNode(1)}<${_tagName2} class="a b"${_attr("other", other)}>${_tagName2}>`);
+ if (_tagName2) _write(`${_markHydrateNode(_scope, 1)}<${_tagName2} class="a b"${_attr("other", other)}>${_tagName2}>`);
- _write(`${_markHydrateNode(2)}<${large ? "h1" : "h2"} class="a b"${_attr("other", other)}>${large ? "h1" : "h2"}>`);
+ _write(`${_markHydrateNode(_scope, 2)}<${large ? "h1" : "h2"} class="a b"${_attr("other", other)}>${large ? "h1" : "h2"}>`);
(showTagA ? tagA : tagB)({
class: ["a", "b"],
@@ -42,9 +44,9 @@ const _renderer = input => {
const _tagName4 = showTagA && tagA;
function _renderBody2() {
- _write("Body content");
-
const _scope = _nextScopeId();
+
+ _write("Body content");
}
if (_tagName4) _tagName4({
@@ -64,15 +66,13 @@ const _renderer = input => {
const _tagName5 = largeHeading || "h2";
- if (_tagName5) _write(`${_markHydrateNode(3)}<${_tagName5} class="a b"${_attr("other", other)}>${_tagName5}>`);
+ if (_tagName5) _write(`${_markHydrateNode(_scope, 3)}<${_tagName5} class="a b"${_attr("other", other)}>${_tagName5}>`);
const tagConstA = "a";
const tagConstB = show ? "div" : null;
- _write(`${_markHydrateNode(4)}<${global.x = "a" + "b"} class="a b"${_attr("other", other)}>${global.x = "a" + "b"}>${_markHydrateNode(5)}<${"h" + level} class="a b"${_attr("other", other)}>${"h" + level}>${_markHydrateNode(6)}
${_markHydrateNode(7)}<${tagConstA} class="a b"${_attr("other", other)}>${tagConstA}>`);
+ _write(`${_markHydrateNode(_scope, 4)}<${global.x = "a" + "b"} class="a b"${_attr("other", other)}>${global.x = "a" + "b"}>${_markHydrateNode(_scope, 5)}<${"h" + level} class="a b"${_attr("other", other)}>${"h" + level}>${_markHydrateNode(_scope, 6)}
${_markHydrateNode(_scope, 7)}<${tagConstA} class="a b"${_attr("other", other)}>${tagConstA}>`);
- if (tagConstB) _write(`${_markHydrateNode(8)}<${tagConstB} class="a b"${_attr("other", other)}>${tagConstB}>`);
-
- const _scope = _nextScopeId();
+ if (tagConstB) _write(`${_markHydrateNode(_scope, 8)}<${tagConstB} class="a b"${_attr("other", other)}>${tagConstB}>`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected.js
index 3c54d706c..6b0cc7c26 100644
--- a/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected.js
@@ -2,6 +2,8 @@ import child from "./components/child/index.marko";
import { nextScopeId as _nextScopeId, markHydrateNode as _markHydrateNode, write as _write, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const data1 = child({
renderBody() {
const _scope = _nextScopeId();
@@ -22,9 +24,7 @@ const _renderer = input => {
const _tagName2 = show && "div";
const el1 = void 0;
- if (_tagName2) _write(`${_markHydrateNode(0)}<${_tagName2}>${_tagName2}>`);
-
- const _scope = _nextScopeId();
+ if (_tagName2) _write(`${_markHydrateNode(_scope, 0)}<${_tagName2}>${_tagName2}>`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected/components/child/index.js b/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected/components/child/index.js
index cc57db7ed..2fc2a3b94 100644
--- a/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected/components/child/index.js
+++ b/packages/translator/src/__tests__/fixtures/dynamic-tag-var/__snapshots__/html.expected/components/child/index.js
@@ -3,10 +3,10 @@ import { nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "
const _renderer = input => {
var _return;
+ const _scope = _nextScopeId();
+
_return = 1;
return _return;
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/effect-counter/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/effect-counter/__snapshots__/html.expected.js
index d18177b9a..2b5130646 100644
--- a/packages/translator/src/__tests__/fixtures/effect-counter/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/effect-counter/__snapshots__/html.expected.js
@@ -1,15 +1,15 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const clickCount = 0;
- _write(`
${_markHydrateNode(0)}0
`);
-
- const _scope = _nextScopeId();
+ _write(`
${_markHydrateNode(_scope, 0)}0
`);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/effect-counter/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [, clickCount]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/effect-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/effect-tag/__snapshots__/html.expected.js
index 57a2e8b56..082f6b417 100644
--- a/packages/translator/src/__tests__/fixtures/effect-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/effect-tag/__snapshots__/html.expected.js
@@ -1,15 +1,15 @@
import { write as _write, nextScopeId as _nextScopeId, writeHydrateCall as _writeHydrateCall, writeHydrateScope as _writeHydrateScope, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const x = 1;
_write("
0
");
- const _scope = _nextScopeId();
-
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/effect-tag/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [x]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/entities/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/entities/__snapshots__/html.expected.js
index 3d7117f76..8410dfeb0 100644
--- a/packages/translator/src/__tests__/fixtures/entities/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/entities/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("Hello John & Suzy Invalid Entity: &b ; Valid Numeric Entity: " Valid Hexadecimal Entity: ¢");
-
const _scope = _nextScopeId();
+
+ _write("Hello John & Suzy Invalid Entity: &b ; Valid Numeric Entity: " Valid Hexadecimal Entity: ¢");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected.js
index 4ffb32b47..d87e94a36 100644
--- a/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected.js
@@ -2,6 +2,8 @@ import { nextScopeId as _nextScopeId, markHydrateNode as _markHydrateNode, write
import _child from "./components/child/index.marko";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
_child({
class: "hi",
onclick: () => {
@@ -14,13 +16,11 @@ const _renderer = input => {
});
- _write(`${_markHydrateNode(0)}
`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}
`);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/event-handlers/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, []);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected/components/child/index.js b/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected/components/child/index.js
index 169055882..3ce7e940e 100644
--- a/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected/components/child/index.js
+++ b/packages/translator/src/__tests__/fixtures/event-handlers/__snapshots__/html.expected/components/child/index.js
@@ -1,9 +1,9 @@
import { dynamicTag as _dynamicTag, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _dynamicTag(input.renderBody, null);
-
const _scope = _nextScopeId();
+
+ _dynamicTag(input.renderBody, null);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected.js
index 88602da28..dd5dea9e0 100644
--- a/packages/translator/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected.js
@@ -1,31 +1,31 @@
import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const arrA = [1, 2, 3];
- _write(`${_markHydrateNode(0)}`);
+ _write(`${_markHydrateNode(_scope, 0)}`);
let _i = 0;
for (const val of arrA) {
let i = _i++;
- _write(`
${_markHydrateNode(0)}${_escapeXML(i)}: ${_markHydrateNode(1)}${_escapeXML(val)}
`);
+ _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(i)}: ${_markHydrateNode(_scope, 1)}${_escapeXML(val)}
`);
}
const arrB = [1, 2, 3];
- _write(`${_markHydrateNode(4)}`);
+ _write(`${_markHydrateNode(_scope, 4)}`);
let _i2 = 0;
for (const val of arrB) {
let i = _i2++;
- _write(`
${_markHydrateNode(0)}${_escapeXML(i)}: ${_markHydrateNode(1)}${_escapeXML(val)}
`);
+ _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(i)}: ${_markHydrateNode(_scope, 1)}${_escapeXML(val)}
`);
}
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/for-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/for-tag/__snapshots__/html.expected.js
index 1e1922479..ad9c1bbff 100644
--- a/packages/translator/src/__tests__/fixtures/for-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/for-tag/__snapshots__/html.expected.js
@@ -1,6 +1,8 @@
import { markHydrateNode as _markHydrateNode, write as _write, escapeXML as _escapeXML, attr as _attr, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const arr = [1, 2, 3];
const obj = {
a: 1,
@@ -8,43 +10,43 @@ const _renderer = input => {
c: 1
};
- _write(`${_markHydrateNode(0)}`);
+ _write(`${_markHydrateNode(_scope, 0)}`);
let _i = 0;
for (const val of arr) {
let i = _i++;
- _write(`
${_markHydrateNode(0)}${_escapeXML(i)}: ${_markHydrateNode(1)}${_escapeXML(val)}
`);
+ _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(i)}: ${_markHydrateNode(_scope, 1)}${_escapeXML(val)}
`);
}
- _write(`${_markHydrateNode(4)}`);
+ _write(`${_markHydrateNode(_scope, 4)}`);
for (const key in obj) {
const val = obj[key];
- _write(`
${_markHydrateNode(0)}${_escapeXML(key)}: ${_markHydrateNode(1)}${_escapeXML(val)}
`);
+ _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(key)}: ${_markHydrateNode(_scope, 1)}${_escapeXML(val)}
`);
}
- _write(`${_markHydrateNode(8)}`);
+ _write(`${_markHydrateNode(_scope, 8)}`);
for (let _steps = (10 - 0) / 2, _step = 0; _step <= _steps; _step++) {
const i = 0 + _step * 2;
- _write(`
${_markHydrateNode(0)}${_escapeXML(i)}
`);
+ _write(`
${_markHydrateNode(_scope, 0)}${_escapeXML(i)}
`);
}
- _write(`${_markHydrateNode(12)}`);
+ _write(`${_markHydrateNode(_scope, 12)}`);
let _i2 = 0;
for (const val of arr) {
let i = _i2++;
- _write(`${_markHydrateNode(0)}
${_markHydrateNode(1)}${_escapeXML(i)}: ${_markHydrateNode(2)}${_escapeXML(val)}
${_markHydrateNode(3)}
`);
+ _write(`${_markHydrateNode(_scope, 0)}
${_markHydrateNode(_scope, 1)}${_escapeXML(i)}: ${_markHydrateNode(_scope, 2)}${_escapeXML(val)}
${_markHydrateNode(_scope, 3)}
`);
}
- _write(`${_markHydrateNode(16)}`);
+ _write(`${_markHydrateNode(_scope, 16)}`);
let _i3 = 0;
const list = arr;
@@ -52,52 +54,50 @@ const _renderer = input => {
for (const val of list) {
let i = _i3++;
- _write(`${_markHydrateNode(0)}
${_markHydrateNode(1)}${_escapeXML(list.length)}: ${_markHydrateNode(2)}${_escapeXML(val)}
`);
+ _write(`${_markHydrateNode(_scope, 0)}
${_markHydrateNode(_scope, 1)}${_escapeXML(list.length)}: ${_markHydrateNode(_scope, 2)}${_escapeXML(val)}
`);
}
- _write(`${_markHydrateNode(20)}`);
+ _write(`${_markHydrateNode(_scope, 20)}`);
for (const key in obj) {
const val = obj[key];
- _write(`${_markHydrateNode(0)}
${_markHydrateNode(1)}${_escapeXML(key)}: ${_markHydrateNode(2)}${_escapeXML(val)}
${_markHydrateNode(3)}
`);
+ _write(`${_markHydrateNode(_scope, 0)}
${_markHydrateNode(_scope, 1)}${_escapeXML(key)}: ${_markHydrateNode(_scope, 2)}${_escapeXML(val)}
${_markHydrateNode(_scope, 3)}
`);
}
- _write(`${_markHydrateNode(24)}`);
+ _write(`${_markHydrateNode(_scope, 24)}`);
for (let _steps3 = (10 - 0) / 2, _step3 = 0; _step3 <= _steps3; _step3++) {
const i = 0 + _step3 * 2;
- _write(`${_markHydrateNode(0)}
${_markHydrateNode(1)}${_escapeXML(i)}
${_markHydrateNode(2)}
${_markHydrateNode(3)}`);
+ _write(`${_markHydrateNode(_scope, 0)}
${_markHydrateNode(_scope, 1)}${_escapeXML(i)}
${_markHydrateNode(_scope, 2)}
${_markHydrateNode(_scope, 3)}`);
for (let _steps2 = (10 - 0) / 2, _step2 = 0; _step2 <= _steps2; _step2++) {
const i = 0 + _step2 * 2;
- _write(`${_markHydrateNode(0)}
${_markHydrateNode(1)}${_escapeXML(i)}
${_markHydrateNode(2)}
`);
+ _write(`${_markHydrateNode(_scope, 0)}
${_markHydrateNode(_scope, 1)}${_escapeXML(i)}
${_markHydrateNode(_scope, 2)}
`);
}
}
- _write(`${_markHydrateNode(28)}`);
+ _write(`${_markHydrateNode(_scope, 28)}`);
for (let _steps4 = (0 - 10) / -2, _step4 = 0; _step4 <= _steps4; _step4++) {
const i = 10 + _step4 * -2;
- _write(`${_markHydrateNode(0)}
${_markHydrateNode(1)}${_escapeXML(i)}
${_markHydrateNode(2)}
`);
+ _write(`${_markHydrateNode(_scope, 0)}
${_markHydrateNode(_scope, 1)}${_escapeXML(i)}
${_markHydrateNode(_scope, 2)}
`);
}
- _write(`${_markHydrateNode(32)}`);
+ _write(`${_markHydrateNode(_scope, 32)}`);
for (let _steps5 = (10 - 0) / 1, _step5 = 0; _step5 <= _steps5; _step5++) {
_write("Hello");
}
- _write(`${_markHydrateNode(36)}`);
+ _write(`${_markHydrateNode(_scope, 36)}`);
for (let _steps6 = (10 - 0) / 1, _step6 = 0; _step6 <= _steps6; _step6++) {
_write("Hello");
}
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/hello-dynamic/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/hello-dynamic/__snapshots__/html.expected.js
index 0c6899ce6..634a63006 100644
--- a/packages/translator/src/__tests__/fixtures/hello-dynamic/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/hello-dynamic/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, toString as _toString, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write(`Hello ${_markHydrateNode(0)}${_escapeXML(name)}! Hello ${_markHydrateNode(1)}${_toString(name)}! Hello ${_markHydrateNode(2)}${_toString(missing)}!`);
-
const _scope = _nextScopeId();
+
+ _write(`Hello ${_markHydrateNode(_scope, 0)}${_escapeXML(name)}! Hello ${_markHydrateNode(_scope, 1)}${_toString(name)}! Hello ${_markHydrateNode(_scope, 2)}${_toString(missing)}!`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/html-entity/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/html-entity/__snapshots__/html.expected.js
index e57766198..47b6101a5 100644
--- a/packages/translator/src/__tests__/fixtures/html-entity/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/html-entity/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
<div>
");
-
const _scope = _nextScopeId();
+
+ _write("
<div>
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/html.expected.js
index 575e1109a..1fc9aaef9 100644
--- a/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/html.expected.js
@@ -1,21 +1,21 @@
import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write(`${_markHydrateNode(0)}`);
+ const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}`);
if (a + b) _write("Hello");
- _write(`${_markHydrateNode(4)}`);
+ _write(`${_markHydrateNode(_scope, 4)}`);
if (a, b) _write("World");
- _write(`
${_markHydrateNode(8)}`);
+ _write(`
${_markHydrateNode(_scope, 8)}`);
if (x) _write("A");else if (y) _write("B");else _write("C");
_write("
");
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/import-tag-conflict/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/import-tag-conflict/__snapshots__/html.expected.js
index 2cf57378a..f4644855e 100644
--- a/packages/translator/src/__tests__/fixtures/import-tag-conflict/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/import-tag-conflict/__snapshots__/html.expected.js
@@ -3,9 +3,9 @@ import { asset as asset2 } from "./asset2";
import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write(`${_markHydrateNode(0)}${_escapeXML(asset1)} ${_markHydrateNode(1)}${_escapeXML(asset2)}`);
-
const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(asset1)} ${_markHydrateNode(_scope, 1)}${_escapeXML(asset2)}`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected.js
index 64ffeddf9..8a0c814ef 100644
--- a/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected.js
@@ -4,6 +4,8 @@ import baz from "./components/baz.marko";
import { nextScopeId as _nextScopeId, markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
baz({
renderBody() {
const _scope = _nextScopeId();
@@ -11,9 +13,7 @@ const _renderer = input => {
});
- _write(`${_markHydrateNode(0)}${_escapeXML(c)}`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(c)}`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected/components/baz.js b/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected/components/baz.js
index 55e32ea45..f2350c3ee 100644
--- a/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected/components/baz.js
+++ b/packages/translator/src/__tests__/fixtures/import-tag/__snapshots__/html.expected/components/baz.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
");
-
const _scope = _nextScopeId();
+
+ _write("
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/input-tracking/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/input-tracking/__snapshots__/html.expected.js
index 4f2b2e9ad..5006b2622 100644
--- a/packages/translator/src/__tests__/fixtures/input-tracking/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/input-tracking/__snapshots__/html.expected.js
@@ -1,14 +1,14 @@
import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const {
a,
b
} = input;
- _write(`${_markHydrateNode(0)}${_escapeXML(a)} ${_markHydrateNode(1)}${_escapeXML(b)}`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}${_escapeXML(a)} ${_markHydrateNode(_scope, 1)}${_escapeXML(b)}`);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/html.expected.js
index b23b96cdc..2d36271ea 100644
--- a/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/html.expected.js
@@ -1,16 +1,16 @@
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";
const _renderer = input => {
+ const _scope = _nextScopeId();
+
const x = 1;
const y = 1;
- _write(`${_markHydrateNode(0)}
${_markHydrateNode(1)}${_escapeXML(x)}
${_markHydrateNode(2)}${_escapeXML(y)}`);
-
- const _scope = _nextScopeId();
+ _write(`${_markHydrateNode(_scope, 0)}
${_markHydrateNode(_scope, 1)}${_escapeXML(x)}
${_markHydrateNode(_scope, 2)}${_escapeXML(y)}`);
_writeHydrateCall(_scope, "packages/translator/src/__tests__/fixtures/let-tag/template.marko_0_0");
- _writeHydrateScope(_scope, {});
+ _writeHydrateScope(_scope, [,,, x, y]);
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/placeholders/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/placeholders/__snapshots__/html.expected.js
index d312d5b85..175029732 100644
--- a/packages/translator/src/__tests__/fixtures/placeholders/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/placeholders/__snapshots__/html.expected.js
@@ -1,11 +1,11 @@
import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, toString as _toString, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write(`
a
${_markHydrateNode(0)}${_escapeXML(x)}Hello Text <a/>${_markHydrateNode(1)}${_toString(x)}Hello HTML
`);
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/style-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/style-tag/__snapshots__/html.expected.js
index ef80845b7..0f6c960ed 100644
--- a/packages/translator/src/__tests__/fixtures/style-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/style-tag/__snapshots__/html.expected.js
@@ -1,9 +1,9 @@
import { write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- _write("
Hello
");
-
const _scope = _nextScopeId();
+
+ _write("
Hello
");
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected.js
index e83c861b0..deec57f6f 100644
--- a/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/tag-tag/__snapshots__/html.expected.js
@@ -1,7 +1,9 @@
import { markHydrateNode as _markHydrateNode, escapeXML as _escapeXML, write as _write, nextScopeId as _nextScopeId, createRenderer as _createRenderer } from "@marko/runtime-fluurt/src/html";
const _renderer = input => {
- const MyTag = input => _write(`Hello ${_markHydrateNode(0)}${_escapeXML(input.name)}`);
+ const _scope = _nextScopeId();
+
+ const MyTag = input => _write(`Hello ${_markHydrateNode(_scope, 0)}${_escapeXML(input.name)}`);
MyTag({
name: "World",
@@ -11,8 +13,6 @@ const _renderer = input => {
}
});
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected.js b/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected.js
index 1afffbd9e..c505c5682 100644
--- a/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected.js
+++ b/packages/translator/src/__tests__/fixtures/yield-tag/__snapshots__/html.expected.js
@@ -3,12 +3,12 @@ import { markHydrateNode as _markHydrateNode, write as _write, nextScopeId as _n
const _renderer = input => {
var _return;
- _write(`${_markHydrateNode(0)}`);
+ const _scope = _nextScopeId();
+
+ _write(`${_markHydrateNode(_scope, 0)}`);
if (show) _return = 1;else _return = 2;
return _return;
-
- const _scope = _nextScopeId();
};
export default _renderer;
diff --git a/packages/translator/src/__tests__/main.test.ts b/packages/translator/src/__tests__/main.test.ts
index aca38d306..b7d67724f 100644
--- a/packages/translator/src/__tests__/main.test.ts
+++ b/packages/translator/src/__tests__/main.test.ts
@@ -102,7 +102,7 @@ describe("translator", () => {
document.open();
const tracker = createTrackMutations(browser.window, document);
- const { /*run,*/ init } = browser.require(
+ const { run, init } = browser.require(
"@marko/runtime-fluurt/src/dom"
) as typeof import("@marko/runtime-fluurt/src/dom");
diff --git a/packages/translator/src/util/apply-hydrate.ts b/packages/translator/src/util/apply-hydrate.ts
index 72a91697e..c7cb855ef 100644
--- a/packages/translator/src/util/apply-hydrate.ts
+++ b/packages/translator/src/util/apply-hydrate.ts
@@ -274,30 +274,59 @@ export function writeHTMLHydrateStatements(
) {
const sectionId = getOrCreateSectionId(path);
const groups = getHydrate(sectionId);
- path.pushContainer(
+
+ path.unshiftContainer(
"body",
t.variableDeclaration("const", [
t.variableDeclarator(scopeIdentifier, callRuntime("nextScopeId")),
])
);
+
+ if (!groups.length) return;
+
+ const refs: Reserve[] = [];
+
for (let i = groups.length; i--; ) {
- path.pushContainer("body", [
+ const { references } = groups[i];
+ if (references) {
+ if (Array.isArray(references)) {
+ for (const ref of references) {
+ sorted.insert(compareReserves, refs, ref);
+ }
+ } else {
+ sorted.insert(compareReserves, refs, references);
+ }
+ }
+ path.pushContainer(
+ "body",
t.expressionStatement(
callRuntime(
"writeHydrateCall",
scopeIdentifier,
t.stringLiteral(getHydrateRegisterId(sectionId, i))
)
- ),
- t.expressionStatement(
- callRuntime(
- "writeHydrateScope",
- scopeIdentifier,
- t.objectExpression([])
- )
- ),
- ]);
+ )
+ );
}
+
+ path.pushContainer(
+ "body",
+ t.expressionStatement(
+ callRuntime(
+ "writeHydrateScope",
+ scopeIdentifier,
+ t.arrayExpression(
+ refs.reduce((acc, ref) => {
+ while (acc.length < ref.id) {
+ acc.push(null);
+ }
+ acc.push(t.identifier(ref.name));
+ return acc;
+ }, [] as Array
)
+ )
+ )
+ )
+ );
}
/**
diff --git a/packages/translator/src/util/walks.ts b/packages/translator/src/util/walks.ts
index 97b805688..df2177852 100644
--- a/packages/translator/src/util/walks.ts
+++ b/packages/translator/src/util/walks.ts
@@ -7,6 +7,7 @@ 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",
@@ -134,6 +135,7 @@ export function visit(
if (code && isOutputHTML()) {
writeTo(path)`${callRuntime(
"markHydrateNode",
+ scopeIdentifier,
t.numericLiteral(reserve!.id)
)}`;
} else {