From f058983081e28f7740319055af7655caf9e0d6d2 Mon Sep 17 00:00:00 2001 From: dpiercey Date: Wed, 1 Jan 2025 07:58:48 -0700 Subject: [PATCH 1/2] feat: add await tag ssr --- .changeset/few-shirts-raise.md | 5 + .../__snapshots__/dom.expected/template.js | 26 +++ .../__snapshots__/html.expected/template.js | 34 ++++ .../__snapshots__/ssr-sanitized.expected.md | 9 + .../await-tag/__snapshots__/ssr.expected.md | 76 +++++++++ .../fixtures/await-tag/template.marko | 22 +++ .../src/__tests__/fixtures/await-tag/test.ts | 7 + .../runtime-tags/src/translator/core/await.ts | 159 ++++++++++++++++++ .../runtime-tags/src/translator/core/index.ts | 2 + .../src/translator/util/references.ts | 2 +- packages/runtime-tags/tag-types/await.d.marko | 8 + 11 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 .changeset/few-shirts-raise.md create mode 100644 packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/dom.expected/template.js create mode 100644 packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/html.expected/template.js create mode 100644 packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md create mode 100644 packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md create mode 100644 packages/runtime-tags/src/__tests__/fixtures/await-tag/template.marko create mode 100644 packages/runtime-tags/src/__tests__/fixtures/await-tag/test.ts create mode 100644 packages/runtime-tags/src/translator/core/await.ts create mode 100644 packages/runtime-tags/tag-types/await.d.marko diff --git a/.changeset/few-shirts-raise.md b/.changeset/few-shirts-raise.md new file mode 100644 index 0000000000..d105fe310b --- /dev/null +++ b/.changeset/few-shirts-raise.md @@ -0,0 +1,5 @@ +--- +"@marko/runtime-tags": patch +--- + +Add await tag ssr. diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/dom.expected/template.js new file mode 100644 index 0000000000..0c57e9bc3e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/dom.expected/template.js @@ -0,0 +1,26 @@ +export const _template_ = "
"; +export const _walks_ = /* next(1), get, out(1) */"D l"; +import { resolveAfter } from "../../utils/resolve"; +import * as _$ from "@marko/runtime-tags/debug/dom"; +const _value$await_content3 = /* @__PURE__ */_$.value("value", (_scope, value) => _$.data(_scope["#text/0"], value)); +const _params_4$await_content = /* @__PURE__ */_$.value("_params_4", (_scope, _params_4) => _value$await_content3(_scope, _params_4[0])); +const _count$await_content3 = /* @__PURE__ */_$.closure("count", (_scope, count) => _$.data(_scope["#text/1"], count)); +const _await_content3 = _$.register("__tests__/template.marko_3_renderer", /* @__PURE__ */_$.createRenderer("Got: ", /* over(1), replace, over(2), replace */"b%c%", void 0, () => [_count$await_content3], () => _params_4$await_content)); +const _value$await_content2 = /* @__PURE__ */_$.value("value", (_scope, value) => _$.data(_scope["#text/0"], value)); +const _params_3$await_content = /* @__PURE__ */_$.value("_params_3", (_scope, _params_3) => _value$await_content2(_scope, _params_3[0])); +const _count$await_content2 = /* @__PURE__ */_$.closure("count", (_scope, count) => _$.data(_scope["#text/1"], count)); +const _await_content2 = _$.register("__tests__/template.marko_2_renderer", /* @__PURE__ */_$.createRenderer("Got: ", /* over(1), replace, over(2), replace */"b%c%", void 0, () => [_count$await_content2], () => _params_3$await_content)); +const _value$await_content = /* @__PURE__ */_$.value("value", (_scope, value) => _$.data(_scope["#text/0"], value)); +const _params_2$await_content = /* @__PURE__ */_$.value("_params_2", (_scope, _params_2) => _value$await_content(_scope, _params_2[0])); +const _count$await_content = /* @__PURE__ */_$.closure("count", (_scope, count) => _$.data(_scope["#text/1"], count)); +const _await_content = _$.register("__tests__/template.marko_1_renderer", /* @__PURE__ */_$.createRenderer("Got: ", /* over(1), replace, over(2), replace */"b%c%", void 0, () => [_count$await_content], () => _params_2$await_content)); +const _count_effect = _$.effect("__tests__/template.marko_0_count", (_scope, { + count +}) => _$.on(_scope["#button/0"], "click", function () { + _count(_scope, count + 1), count; +})); +const _count = /* @__PURE__ */_$.state("count", (_scope, count) => _count_effect(_scope), () => _$.intersections([_count$await_content, _count$await_content2, _count$await_content3])); +export function _setup_(_scope) { + _count(_scope, 0); +} +export default /* @__PURE__ */_$.createTemplate("__tests__/template.marko", _template_, _walks_, _setup_); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/html.expected/template.js new file mode 100644 index 0000000000..0ee138faeb --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/html.expected/template.js @@ -0,0 +1,34 @@ +import { resolveAfter } from "../../utils/resolve"; +import * as _$ from "@marko/runtime-tags/debug/html"; +const _renderer = /* @__PURE__ */_$.createRenderer((input, _tagVar) => { + const _scope0_id = _$.nextScopeId(); + const count = 0; + _$.write("
"); + _$.fork(Promise.resolve("a"), value => { + const _scope1_id = _$.nextScopeId(); + _$.write(`Got: ${_$.escapeXML(value)} ${_$.escapeXML(count)}${_$.markResumeNode(_scope1_id, "#text/1")}`); + _$.writeScope(_scope1_id, { + "_": _$.ensureScopeWithId(_scope0_id) + }); + }); + _$.fork(resolveAfter("b", 2), value => { + const _scope2_id = _$.nextScopeId(); + _$.write(`Got: ${_$.escapeXML(value)} ${_$.escapeXML(count)}${_$.markResumeNode(_scope2_id, "#text/1")}`); + _$.writeScope(_scope2_id, { + "_": _$.ensureScopeWithId(_scope0_id) + }); + }); + _$.fork(resolveAfter("c", 1), value => { + const _scope3_id = _$.nextScopeId(); + _$.write(`Got: ${_$.escapeXML(value)} ${_$.escapeXML(count)}${_$.markResumeNode(_scope3_id, "#text/1")}`); + _$.writeScope(_scope3_id, { + "_": _$.ensureScopeWithId(_scope0_id) + }); + }); + _$.write(`${_$.markResumeNode(_scope0_id, "#button/0")}
`); + _$.writeEffect(_scope0_id, "__tests__/template.marko_0_count"); + _$.writeScope(_scope0_id, { + "count": count + }); +}); +export default /* @__PURE__ */_$.createTemplate("__tests__/template.marko", _renderer); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md new file mode 100644 index 0000000000..737b6f378d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md @@ -0,0 +1,9 @@ +# Render "End" +```html +
+ Got: a 0Got: b 0Got: c 0 + +
+``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md new file mode 100644 index 0000000000..c4729dbe04 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md @@ -0,0 +1,76 @@ +# Write +
Got: a 0 + + +# Write + + + +# Write + Got: b 0Got: c 0
+ + +# Render "End" +```html + + + +
+ Got: a + + 0 + + + + Got: b + + 0 + + Got: c + + 0 + + + +
+ + + +``` + +# Mutations +``` +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/div0 +inserted #document/html0/body1/div0/#text0 +inserted #document/html0/body1/div0/#comment1 +inserted #document/html0/body1/div0/#text2 +inserted #document/html0/body1/div0/#comment3 +inserted #document/html0/body1/div0/script4 +inserted #document/html0/body1/div0/script4/#text0 +inserted #document/html0/body1/div0/script5 +inserted #document/html0/body1/div0/script5/#text0 +inserted #document/html0/body1/div0/#text6 +inserted #document/html0/body1/div0/#comment7 +inserted #document/html0/body1/div0/#text8 +inserted #document/html0/body1/div0/#comment9 +inserted #document/html0/body1/div0/#text10 +inserted #document/html0/body1/div0/#comment11 +inserted #document/html0/body1/div0/#text12 +inserted #document/html0/body1/div0/#comment13 +inserted #document/html0/body1/div0/button14 +inserted #document/html0/body1/div0/button14/#text0 +inserted #document/html0/body1/div0/#comment15 +inserted #document/html0/body1/script1 +inserted #document/html0/body1/script1/#text0 +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/template.marko b/packages/runtime-tags/src/__tests__/fixtures/await-tag/template.marko new file mode 100644 index 0000000000..cc846f16d6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/template.marko @@ -0,0 +1,22 @@ +import { resolveAfter } from "../../utils/resolve"; + + +
+ + Got: ${value} ${count} + + + + Got: ${value} ${count} + + + + Got: ${value} ${count} + + + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/test.ts b/packages/runtime-tags/src/__tests__/fixtures/await-tag/test.ts new file mode 100644 index 0000000000..ab029d1de9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/test.ts @@ -0,0 +1,7 @@ +export const skip_csr = true; + +export const steps = [{}, click, click, click]; + +function click(container: Element) { + container.querySelector("button")!.click(); +} diff --git a/packages/runtime-tags/src/translator/core/await.ts b/packages/runtime-tags/src/translator/core/await.ts new file mode 100644 index 0000000000..66f30588e2 --- /dev/null +++ b/packages/runtime-tags/src/translator/core/await.ts @@ -0,0 +1,159 @@ +import { types as t } from "@marko/compiler"; +import { + assertNoArgs, + assertNoAttributeTags, + assertNoVar, + type Tag, +} from "@marko/compiler/babel-utils"; + +import { assertNoSpreadAttrs } from "../util/assert"; +import evaluate from "../util/evaluate"; +import { isStatefulReferences } from "../util/is-stateful"; +import { BindingType, trackParamsReferences } from "../util/references"; +import { callRuntime } from "../util/runtime"; +import runtimeInfo from "../util/runtime-info"; +import { + checkStatefulClosures, + getOrCreateSection, + getSectionForBody, + setSectionParentIsOwner, +} from "../util/sections"; +import { + setForceResumeScope, + setSubscriberBuilder, + writeHTMLResumeStatements, +} from "../util/signals"; +import { toFirstExpressionOrBlock } from "../util/to-first-expression-or-block"; +import { translateByTarget } from "../util/visitors"; +import * as writer from "../util/writer"; + +export default { + analyze(tag: t.NodePath) { + assertNoVar(tag); + assertNoArgs(tag); + assertNoSpreadAttrs(tag); + assertNoAttributeTags(tag); + const { node } = tag; + const [valueAttr] = node.attributes; + + if (!valueAttr) { + throw tag + .get("name") + .buildCodeFrameError("The `await` tag requires a value."); + } + + if ( + node.attributes.length > 1 || + !t.isMarkoAttribute(valueAttr) || + valueAttr.name !== "value" + ) { + throw tag + .get("name") + .buildCodeFrameError( + "The `await` tag only supports the `value` attribute.", + ); + } + + if (!node.body.body.length) { + throw tag + .get("name") + .buildCodeFrameError("The `await` tag requires body content."); + } + + if ( + node.body.params.length && + (node.body.params.length > 1 || t.isSpreadElement(node.body.params[0])) + ) { + throw tag + .get("name") + .buildCodeFrameError( + "The `await` tag only supports a single parameter.", + ); + } + + getOrCreateSection(tag); + trackParamsReferences( + tag.get("body"), + BindingType.derived, + undefined, + evaluate(valueAttr.value), + ); + }, + translate: translateByTarget({ + html: { + enter(tag) { + const tagBody = tag.get("body"); + const bodySection = getSectionForBody(tagBody); + + if (!bodySection) { + tag.remove(); + return; + } + + setSectionParentIsOwner(bodySection, true); + writer.flushBefore(tag); + }, + exit(tag) { + const { node } = tag; + const [valueAttr] = node.attributes; + const tagBody = tag.get("body"); + const bodySection = getSectionForBody(tagBody)!; + + if ( + isStatefulReferences(valueAttr.extra?.referencedBindings) || + checkStatefulClosures(bodySection, true) + ) { + setForceResumeScope(bodySection); + } + + writer.flushInto(tag); + // TODO: this is a hack to get around the fact that we don't have a way to + // know if a scope requires dynamic subscriptions + setSubscriberBuilder(tag, (() => {}) as any); + writeHTMLResumeStatements(tagBody); + + tag + .replaceWith( + t.expressionStatement( + callRuntime( + "fork", + valueAttr.value, + t.arrowFunctionExpression( + node.body.params, + toFirstExpressionOrBlock(node.body.body), + ), + ), + ), + )[0] + .skip(); + }, + }, + dom: { + enter(tag) { + const tagBody = tag.get("body"); + const bodySection = getSectionForBody(tagBody); + + if (!bodySection) { + tag.remove(); + return; + } + + setSectionParentIsOwner(bodySection, true); + // TODO: this is a hack to get around the fact that we don't have a way to + // know if a scope requires dynamic subscriptions + setSubscriberBuilder(tag, (signal) => signal); + }, + exit(tag) { + tag.remove(); + }, + }, + }), + attributes: {}, + autocomplete: [ + { + description: "Use to consume asynchronous an data.", + descriptionMoreURL: "https://markojs.com/docs/core-tags/#await", + }, + ], + types: runtimeInfo.name + "/tag-types/await.d.marko", +} as Tag; diff --git a/packages/runtime-tags/src/translator/core/index.ts b/packages/runtime-tags/src/translator/core/index.ts index 311e63e4f7..0b460482fb 100644 --- a/packages/runtime-tags/src/translator/core/index.ts +++ b/packages/runtime-tags/src/translator/core/index.ts @@ -1,5 +1,6 @@ import runtimeInfo from "../util/runtime-info"; import AttrsTag from "./attrs"; +import AwaitTag from "./await"; import ClientTag from "./client"; import ConstTag from "./const"; import DebugTag from "./debug"; @@ -25,6 +26,7 @@ import StyleTag from "./style"; export default { taglibId: runtimeInfo.taglibId, "": AttrsTag, + "": AwaitTag, "": ClientTag, "": ConstTag, "": DebugTag, diff --git a/packages/runtime-tags/src/translator/util/references.ts b/packages/runtime-tags/src/translator/util/references.ts index edba3ee8e0..d3fdfa3c39 100644 --- a/packages/runtime-tags/src/translator/util/references.ts +++ b/packages/runtime-tags/src/translator/util/references.ts @@ -191,7 +191,7 @@ export function trackParamsReferences( body.scope, section, paramsBinding, - undefined, + upstreamExpression, i + "", ); } diff --git a/packages/runtime-tags/tag-types/await.d.marko b/packages/runtime-tags/tag-types/await.d.marko new file mode 100644 index 0000000000..db3e2dc7c2 --- /dev/null +++ b/packages/runtime-tags/tag-types/await.d.marko @@ -0,0 +1,8 @@ +/** File for types only, not actual implementation **/ + +export interface Input { + value: T; + content: Marko.Body<[Awaited]> +} + +return=input.value From 7b2b38ed6568ba1b5d1f48cbac52ce97df9a7138 Mon Sep 17 00:00:00 2001 From: dpiercey Date: Thu, 9 Jan 2025 10:14:00 -0700 Subject: [PATCH 2/2] feat: add basic ssr try tag --- .changeset/eight-poems-promise.md | 5 + .../__snapshots__/html.expected/template.js | 2 +- .../__snapshots__/resume.expected.md | 48 -- .../__snapshots__/ssr.expected.md | 26 +- .../catch-single-reject-async/server.ts | 15 +- .../catch-single-success-async/server.ts | 14 +- .../catch-single-success-sync/server.ts | 14 +- .../catch-single-throw-sync/server.ts | 14 +- .../server.ts | 26 +- .../__snapshots__/html.expected/template.js | 4 +- .../__snapshots__/resume.expected.md | 9 - .../__snapshots__/ssr.expected.md | 19 +- .../__snapshots__/html.expected/template.js | 2 +- .../__snapshots__/resume.expected.md | 21 +- .../__snapshots__/ssr.expected.md | 38 +- .../__snapshots__/html.expected/template.js | 16 +- .../for-tag/__snapshots__/resume.expected.md | 249 +------ .../for-tag/__snapshots__/ssr.expected.md | 693 +++--------------- .../fixtures/placeholder-single/server.ts | 15 +- .../fixtures/placeholder-skipped/server.ts | 15 +- .../fixtures/placeholders-nested/server.ts | 28 +- .../__snapshots__/html.expected/template.js | 21 + .../__snapshots__/ssr-sanitized.expected.md | 4 + .../__snapshots__/ssr.expected.md | 30 + .../try-single-throw-sync/template.marko | 8 + .../fixtures/try-single-throw-sync/test.ts | 1 + packages/runtime-tags/src/html.ts | 3 +- .../runtime-tags/src/html/inlined-runtimes.ts | 6 +- packages/runtime-tags/src/html/writer.ts | 36 +- .../src/translator/core/define.ts | 2 + .../runtime-tags/src/translator/core/index.ts | 2 + .../runtime-tags/src/translator/core/try.ts | 112 +++ .../src/translator/util/signals.ts | 1 - packages/runtime-tags/tag-types/try.d.marko | 7 + 34 files changed, 465 insertions(+), 1041 deletions(-) create mode 100644 .changeset/eight-poems-promise.md create mode 100644 packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.expected/template.js create mode 100644 packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr-sanitized.expected.md create mode 100644 packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr.expected.md create mode 100644 packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/template.marko create mode 100644 packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/test.ts create mode 100644 packages/runtime-tags/src/translator/core/try.ts create mode 100644 packages/runtime-tags/tag-types/try.d.marko diff --git a/.changeset/eight-poems-promise.md b/.changeset/eight-poems-promise.md new file mode 100644 index 0000000000..afe77fb5b8 --- /dev/null +++ b/.changeset/eight-poems-promise.md @@ -0,0 +1,5 @@ +--- +"@marko/runtime-tags": patch +--- + +Add basic ssr try tag. diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js index 1fdf2bfaf9..9c8b6e196f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/html.expected/template.js @@ -5,7 +5,7 @@ const _renderer = /* @__PURE__ */_$.createRenderer((input, _tagVar) => { const _scope1_ = new Map(); _$.forOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], (num, _index) => { const _scope1_id = _$.nextScopeId(); - _$.write(`${_$.escapeXML(num)}${_$.markResumeNode(_scope1_id, "#text/1")}${_$.markResumeNode(_scope1_id, "#button/0")}`); + _$.write(`${_$.escapeXML(num)}${_$.markResumeNode(_scope1_id, "#button/0")}`); _$.writeEffect(_scope1_id, "__tests__/template.marko_1_num"); _$.writeScope(_scope1_id, { "num": num, diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/resume.expected.md index 328cd53609..b58bef977b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/resume.expected.md @@ -5,62 +5,50 @@ + # Render "End" @@ -9,62 +9,50 @@ ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-siblings/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/for-tag-siblings/__snapshots__/ssr.expected.md index f4f98f0f0c..91cd3d34d4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-siblings/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-siblings/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
1
2
3
1
2
3
+
1
2
3
1
2
3
# Render "End" @@ -10,35 +10,26 @@
1 -
2 -
3 -
1 -
2 -
3 -
- ``` @@ -51,24 +42,16 @@ inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/div0 inserted #document/html0/body1/div0/div0/#text0 -inserted #document/html0/body1/div0/div0/#comment1 inserted #document/html0/body1/div0/div1 inserted #document/html0/body1/div0/div1/#text0 -inserted #document/html0/body1/div0/div1/#comment1 inserted #document/html0/body1/div0/div2 inserted #document/html0/body1/div0/div2/#text0 -inserted #document/html0/body1/div0/div2/#comment1 inserted #document/html0/body1/div1 inserted #document/html0/body1/div1/div0 inserted #document/html0/body1/div1/div0/#text0 -inserted #document/html0/body1/div1/div0/#comment1 inserted #document/html0/body1/div1/div1 inserted #document/html0/body1/div1/div1/#text0 -inserted #document/html0/body1/div1/div1/#comment1 inserted #document/html0/body1/div1/div2 inserted #document/html0/body1/div1/div2/#text0 -inserted #document/html0/body1/div1/div2/#comment1 inserted #document/html0/body1/div1/div3 -inserted #document/html0/body1/script2 -inserted #document/html0/body1/script2/#text0 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected/template.js index 84df10cf41..3c056efad9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/html.expected/template.js @@ -4,7 +4,7 @@ const _renderer = /* @__PURE__ */_$.createRenderer((input, _tagVar) => { const arrA = [1, 2, 3]; _$.forOf(arrA, (val, i) => { const _scope1_id = _$.nextScopeId(); - _$.write(`
${_$.escapeXML(i)}${_$.markResumeNode(_scope1_id, "#text/0")}: ${_$.escapeXML(val)}${_$.markResumeNode(_scope1_id, "#text/1")}
`); + _$.write(`
${_$.escapeXML(i)}: ${_$.escapeXML(val)}
`); }); const arrB = [1, 2, 3]; const _forScopeIds = [], diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/resume.expected.md index 2af391fa69..b5b851e704 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/resume.expected.md @@ -4,28 +4,13 @@
- 0 - - : - - 1 - + 0: 1
- 1 - - : - - 2 - + 1: 2
- 2 - - : - - 3 - + 2: 3
0 diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/ssr.expected.md index e8ceb7e1bf..94f9f57792 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag-with-state/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
0: 1
1: 2
2: 3
0: 1
1: 2
2: 3
+
0: 1
1: 2
2: 3
0: 1
1: 2
2: 3
# Render "End" @@ -8,28 +8,13 @@
- 0 - - : - - 1 - + 0: 1
- 1 - - : - - 2 - + 1: 2
- 2 - - : - - 3 - + 2: 3
0 @@ -70,25 +55,10 @@ inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/#text0 -inserted #document/html0/body1/div0/#comment1 -inserted #document/html0/body1/div0/#text2 -inserted #document/html0/body1/div0/#comment3 -inserted #document/html0/body1/div0/#text4 -inserted #document/html0/body1/div0/#comment5 inserted #document/html0/body1/div1 inserted #document/html0/body1/div1/#text0 -inserted #document/html0/body1/div1/#comment1 -inserted #document/html0/body1/div1/#text2 -inserted #document/html0/body1/div1/#comment3 -inserted #document/html0/body1/div1/#text4 -inserted #document/html0/body1/div1/#comment5 inserted #document/html0/body1/div2 inserted #document/html0/body1/div2/#text0 -inserted #document/html0/body1/div2/#comment1 -inserted #document/html0/body1/div2/#text2 -inserted #document/html0/body1/div2/#comment3 -inserted #document/html0/body1/div2/#text4 -inserted #document/html0/body1/div2/#comment5 inserted #document/html0/body1/div3 inserted #document/html0/body1/div3/#text0 inserted #document/html0/body1/div3/#comment1 diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/html.expected/template.js index 72f76b868d..b2d764c7d4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/html.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/html.expected/template.js @@ -9,35 +9,35 @@ const _renderer = /* @__PURE__ */_$.createRenderer((input, _tagVar) => { }; _$.forOf(arr, (val, i) => { const _scope1_id = _$.nextScopeId(); - _$.write(`
${_$.escapeXML(i)}${_$.markResumeNode(_scope1_id, "#text/0")}: ${_$.escapeXML(val)}${_$.markResumeNode(_scope1_id, "#text/1")}
`); + _$.write(`
${_$.escapeXML(i)}: ${_$.escapeXML(val)}
`); }); _$.forIn(obj, (key, val) => { const _scope2_id = _$.nextScopeId(); - _$.write(`
${_$.escapeXML(key)}${_$.markResumeNode(_scope2_id, "#text/0")}: ${_$.escapeXML(val)}${_$.markResumeNode(_scope2_id, "#text/1")}
`); + _$.write(`
${_$.escapeXML(key)}: ${_$.escapeXML(val)}
`); }); _$.forTo(10, 0, 2, i => { const _scope3_id = _$.nextScopeId(); - _$.write(`
${_$.escapeXML(i)}${_$.markResumeNode(_scope3_id, "#text/0")}
`); + _$.write(`
${_$.escapeXML(i)}
`); }); _$.forOf(arr, (val, i) => { const _scope4_id = _$.nextScopeId(); - _$.write(`${_$.escapeXML(i)}${_$.markResumeNode(_scope4_id, "#text/1")}: ${_$.escapeXML(val)}${_$.markResumeNode(_scope4_id, "#text/2")}
${_$.markResumeNode(_scope4_id, "#div/0")}
${_$.markResumeNode(_scope4_id, "#div/3")}`); + _$.write(`${_$.escapeXML(i)}: ${_$.escapeXML(val)}
`); }); _$.forIn(obj, (key, val) => { const _scope5_id = _$.nextScopeId(); - _$.write(`${_$.escapeXML(key)}${_$.markResumeNode(_scope5_id, "#text/1")}: ${_$.escapeXML(val)}${_$.markResumeNode(_scope5_id, "#text/2")}${_$.markResumeNode(_scope5_id, "#div/0")}
${_$.markResumeNode(_scope5_id, "#div/3")}`); + _$.write(`${_$.escapeXML(key)}: ${_$.escapeXML(val)}
`); }); _$.forTo(10, 0, 2, i => { const _scope6_id = _$.nextScopeId(); - _$.write(`${_$.escapeXML(i)}${_$.markResumeNode(_scope6_id, "#text/1")}${_$.markResumeNode(_scope6_id, "#div/0")}
${_$.markResumeNode(_scope6_id, "#div/2")}`); + _$.write(`${_$.escapeXML(i)}
`); _$.forTo(10, 0, 2, i => { const _scope7_id = _$.nextScopeId(); - _$.write(`${_$.escapeXML(i)}${_$.markResumeNode(_scope7_id, "#text/1")}${_$.markResumeNode(_scope7_id, "#div/0")}
${_$.markResumeNode(_scope7_id, "#div/2")}`); + _$.write(`${_$.escapeXML(i)}
`); }); }); _$.forTo(0, 10, -2, i => { const _scope8_id = _$.nextScopeId(); - _$.write(`${_$.escapeXML(i)}${_$.markResumeNode(_scope8_id, "#text/1")}${_$.markResumeNode(_scope8_id, "#div/0")}
${_$.markResumeNode(_scope8_id, "#div/2")}`); + _$.write(`${_$.escapeXML(i)}
`); }); _$.forTo(10, 0, 1, () => { const _scope9_id = _$.nextScopeId(); diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/resume.expected.md index f9ddfbda19..16542051d1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/resume.expected.md @@ -4,777 +4,552 @@
- 0 - - : - - 1 - + 0: 1
- 1 - - : - - 2 - + 1: 2
- 2 - - : - - 3 - + 2: 3
- a - - : - - 1 - + a: 1
- b - - : - - 1 - + b: 1
- c - - : - - 1 - + c: 1
0 -
2 -
4 -
6 -
8 -
10 -
- 0 - - : - - 1 - + 0: 1
-
-
- 1 - - : - - 2 - + 1: 2
-
-
- 2 - - : - - 3 - + 2: 3
-
-
- a - - : - - 1 - + a: 1
-
-
- b - - : - - 1 - + b: 1
-
-
- c - - : - - 1 - + c: 1
-
-
0 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
2 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
4 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
6 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
8 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
10 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
10 -
-
-
8 -
-
-
6 -
-
-
4 -
-
-
2 -
-
-
0 -
-
- HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello - ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/ssr.expected.md index a2d56a39a9..6fe355ff35 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/for-tag/__snapshots__/ssr.expected.md @@ -1,5 +1,5 @@ # Write -
0: 1
1: 2
2: 3
a: 1
b: 1
c: 1
0
2
4
6
8
10
0: 1
1: 2
2: 3
a: 1
b: 1
c: 1
0
0
2
4
6
8
10
2
0
2
4
6
8
10
4
0
2
4
6
8
10
6
0
2
4
6
8
10
8
0
2
4
6
8
10
10
0
2
4
6
8
10
10
8
6
4
2
0
HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello +
0: 1
1: 2
2: 3
a: 1
b: 1
c: 1
0
2
4
6
8
10
0: 1
1: 2
2: 3
a: 1
b: 1
c: 1
0
0
2
4
6
8
10
2
0
2
4
6
8
10
4
0
2
4
6
8
10
6
0
2
4
6
8
10
8
0
2
4
6
8
10
10
0
2
4
6
8
10
10
8
6
4
2
0
HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello # Render "End" @@ -8,777 +8,552 @@
- 0 - - : - - 1 - + 0: 1
- 1 - - : - - 2 - + 1: 2
- 2 - - : - - 3 - + 2: 3
- a - - : - - 1 - + a: 1
- b - - : - - 1 - + b: 1
- c - - : - - 1 - + c: 1
0 -
2 -
4 -
6 -
8 -
10 -
- 0 - - : - - 1 - + 0: 1
-
-
- 1 - - : - - 2 - + 1: 2
-
-
- 2 - - : - - 3 - + 2: 3
-
-
- a - - : - - 1 - + a: 1
-
-
- b - - : - - 1 - + b: 1
-
-
- c - - : - - 1 - + c: 1
-
-
0 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
2 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
4 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
6 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
8 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
10 -
-
-
0 -
-
-
2 -
-
-
4 -
-
-
6 -
-
-
8 -
-
-
10 -
-
-
10 -
-
-
8 -
-
-
6 -
-
-
4 -
-
-
2 -
-
-
0 -
-
- HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello - ``` @@ -790,491 +565,267 @@ inserted #document/html0/head0 inserted #document/html0/body1 inserted #document/html0/body1/div0 inserted #document/html0/body1/div0/#text0 -inserted #document/html0/body1/div0/#comment1 -inserted #document/html0/body1/div0/#text2 -inserted #document/html0/body1/div0/#comment3 -inserted #document/html0/body1/div0/#text4 -inserted #document/html0/body1/div0/#comment5 inserted #document/html0/body1/div1 inserted #document/html0/body1/div2 inserted #document/html0/body1/div3 inserted #document/html0/body1/div3/#text0 -inserted #document/html0/body1/div3/#comment1 -inserted #document/html0/body1/div3/#text2 -inserted #document/html0/body1/div3/#comment3 -inserted #document/html0/body1/div3/#text4 -inserted #document/html0/body1/div3/#comment5 inserted #document/html0/body1/div4 inserted #document/html0/body1/div5 inserted #document/html0/body1/div6 inserted #document/html0/body1/div6/#text0 -inserted #document/html0/body1/div6/#comment1 -inserted #document/html0/body1/div6/#text2 -inserted #document/html0/body1/div6/#comment3 -inserted #document/html0/body1/div6/#text4 -inserted #document/html0/body1/div6/#comment5 inserted #document/html0/body1/div7 inserted #document/html0/body1/div8 inserted #document/html0/body1/div9 inserted #document/html0/body1/div9/#text0 -inserted #document/html0/body1/div9/#comment1 -inserted #document/html0/body1/div9/#text2 -inserted #document/html0/body1/div9/#comment3 -inserted #document/html0/body1/div9/#text4 -inserted #document/html0/body1/div9/#comment5 inserted #document/html0/body1/div10 inserted #document/html0/body1/div11 inserted #document/html0/body1/div12 inserted #document/html0/body1/div12/#text0 -inserted #document/html0/body1/div12/#comment1 -inserted #document/html0/body1/div12/#text2 -inserted #document/html0/body1/div12/#comment3 -inserted #document/html0/body1/div12/#text4 -inserted #document/html0/body1/div12/#comment5 inserted #document/html0/body1/div13 inserted #document/html0/body1/div14 inserted #document/html0/body1/div15 inserted #document/html0/body1/div15/#text0 -inserted #document/html0/body1/div15/#comment1 -inserted #document/html0/body1/div15/#text2 -inserted #document/html0/body1/div15/#comment3 -inserted #document/html0/body1/div15/#text4 -inserted #document/html0/body1/div15/#comment5 inserted #document/html0/body1/div16 inserted #document/html0/body1/div17 inserted #document/html0/body1/div18 inserted #document/html0/body1/div18/#text0 -inserted #document/html0/body1/div18/#comment1 inserted #document/html0/body1/div19 inserted #document/html0/body1/div20 inserted #document/html0/body1/div21 inserted #document/html0/body1/div21/#text0 -inserted #document/html0/body1/div21/#comment1 inserted #document/html0/body1/div22 inserted #document/html0/body1/div23 inserted #document/html0/body1/div24 inserted #document/html0/body1/div24/#text0 -inserted #document/html0/body1/div24/#comment1 inserted #document/html0/body1/div25 inserted #document/html0/body1/div26 inserted #document/html0/body1/div27 inserted #document/html0/body1/div27/#text0 -inserted #document/html0/body1/div27/#comment1 inserted #document/html0/body1/div28 inserted #document/html0/body1/div29 inserted #document/html0/body1/div30 inserted #document/html0/body1/div30/#text0 -inserted #document/html0/body1/div30/#comment1 inserted #document/html0/body1/div31 inserted #document/html0/body1/div32 inserted #document/html0/body1/div33 inserted #document/html0/body1/div33/#text0 -inserted #document/html0/body1/div33/#comment1 inserted #document/html0/body1/div34 inserted #document/html0/body1/div35 inserted #document/html0/body1/div36 inserted #document/html0/body1/div36/#text0 -inserted #document/html0/body1/div36/#comment1 -inserted #document/html0/body1/div36/#text2 -inserted #document/html0/body1/div36/#comment3 -inserted #document/html0/body1/div36/#text4 -inserted #document/html0/body1/div36/#comment5 -inserted #document/html0/body1/#comment37 +inserted #document/html0/body1/div37 inserted #document/html0/body1/div38 inserted #document/html0/body1/div39 -inserted #document/html0/body1/#comment40 +inserted #document/html0/body1/div39/#text0 +inserted #document/html0/body1/div40 inserted #document/html0/body1/div41 -inserted #document/html0/body1/div41/#text0 -inserted #document/html0/body1/div41/#comment1 -inserted #document/html0/body1/div41/#text2 -inserted #document/html0/body1/div41/#comment3 -inserted #document/html0/body1/div41/#text4 -inserted #document/html0/body1/div41/#comment5 -inserted #document/html0/body1/#comment42 +inserted #document/html0/body1/div42 +inserted #document/html0/body1/div42/#text0 inserted #document/html0/body1/div43 inserted #document/html0/body1/div44 -inserted #document/html0/body1/#comment45 +inserted #document/html0/body1/div45 +inserted #document/html0/body1/div45/#text0 inserted #document/html0/body1/div46 -inserted #document/html0/body1/div46/#text0 -inserted #document/html0/body1/div46/#comment1 -inserted #document/html0/body1/div46/#text2 -inserted #document/html0/body1/div46/#comment3 -inserted #document/html0/body1/div46/#text4 -inserted #document/html0/body1/div46/#comment5 -inserted #document/html0/body1/#comment47 +inserted #document/html0/body1/div47 inserted #document/html0/body1/div48 +inserted #document/html0/body1/div48/#text0 inserted #document/html0/body1/div49 -inserted #document/html0/body1/#comment50 +inserted #document/html0/body1/div50 inserted #document/html0/body1/div51 inserted #document/html0/body1/div51/#text0 -inserted #document/html0/body1/div51/#comment1 -inserted #document/html0/body1/div51/#text2 -inserted #document/html0/body1/div51/#comment3 -inserted #document/html0/body1/div51/#text4 -inserted #document/html0/body1/div51/#comment5 -inserted #document/html0/body1/#comment52 +inserted #document/html0/body1/div52 inserted #document/html0/body1/div53 inserted #document/html0/body1/div54 -inserted #document/html0/body1/#comment55 +inserted #document/html0/body1/div54/#text0 +inserted #document/html0/body1/div55 inserted #document/html0/body1/div56 -inserted #document/html0/body1/div56/#text0 -inserted #document/html0/body1/div56/#comment1 -inserted #document/html0/body1/div56/#text2 -inserted #document/html0/body1/div56/#comment3 -inserted #document/html0/body1/div56/#text4 -inserted #document/html0/body1/div56/#comment5 -inserted #document/html0/body1/#comment57 +inserted #document/html0/body1/div57 +inserted #document/html0/body1/div57/#text0 inserted #document/html0/body1/div58 inserted #document/html0/body1/div59 -inserted #document/html0/body1/#comment60 +inserted #document/html0/body1/div60 +inserted #document/html0/body1/div60/#text0 inserted #document/html0/body1/div61 -inserted #document/html0/body1/div61/#text0 -inserted #document/html0/body1/div61/#comment1 -inserted #document/html0/body1/div61/#text2 -inserted #document/html0/body1/div61/#comment3 -inserted #document/html0/body1/div61/#text4 -inserted #document/html0/body1/div61/#comment5 -inserted #document/html0/body1/#comment62 +inserted #document/html0/body1/div62 inserted #document/html0/body1/div63 +inserted #document/html0/body1/div63/#text0 inserted #document/html0/body1/div64 -inserted #document/html0/body1/#comment65 +inserted #document/html0/body1/div65 inserted #document/html0/body1/div66 inserted #document/html0/body1/div66/#text0 -inserted #document/html0/body1/div66/#comment1 -inserted #document/html0/body1/#comment67 +inserted #document/html0/body1/div67 inserted #document/html0/body1/div68 inserted #document/html0/body1/div69 -inserted #document/html0/body1/#comment70 +inserted #document/html0/body1/div69/#text0 +inserted #document/html0/body1/div70 inserted #document/html0/body1/div71 -inserted #document/html0/body1/div71/#text0 -inserted #document/html0/body1/div71/#comment1 -inserted #document/html0/body1/#comment72 +inserted #document/html0/body1/div72 +inserted #document/html0/body1/div72/#text0 inserted #document/html0/body1/div73 inserted #document/html0/body1/div74 -inserted #document/html0/body1/#comment75 +inserted #document/html0/body1/div75 +inserted #document/html0/body1/div75/#text0 inserted #document/html0/body1/div76 -inserted #document/html0/body1/div76/#text0 -inserted #document/html0/body1/div76/#comment1 -inserted #document/html0/body1/#comment77 +inserted #document/html0/body1/div77 inserted #document/html0/body1/div78 +inserted #document/html0/body1/div78/#text0 inserted #document/html0/body1/div79 -inserted #document/html0/body1/#comment80 +inserted #document/html0/body1/div80 inserted #document/html0/body1/div81 inserted #document/html0/body1/div81/#text0 -inserted #document/html0/body1/div81/#comment1 -inserted #document/html0/body1/#comment82 +inserted #document/html0/body1/div82 inserted #document/html0/body1/div83 inserted #document/html0/body1/div84 -inserted #document/html0/body1/#comment85 +inserted #document/html0/body1/div84/#text0 +inserted #document/html0/body1/div85 inserted #document/html0/body1/div86 -inserted #document/html0/body1/div86/#text0 -inserted #document/html0/body1/div86/#comment1 -inserted #document/html0/body1/#comment87 +inserted #document/html0/body1/div87 +inserted #document/html0/body1/div87/#text0 inserted #document/html0/body1/div88 inserted #document/html0/body1/div89 -inserted #document/html0/body1/#comment90 +inserted #document/html0/body1/div90 +inserted #document/html0/body1/div90/#text0 inserted #document/html0/body1/div91 -inserted #document/html0/body1/div91/#text0 -inserted #document/html0/body1/div91/#comment1 -inserted #document/html0/body1/#comment92 +inserted #document/html0/body1/div92 inserted #document/html0/body1/div93 +inserted #document/html0/body1/div93/#text0 inserted #document/html0/body1/div94 -inserted #document/html0/body1/#comment95 +inserted #document/html0/body1/div95 inserted #document/html0/body1/div96 inserted #document/html0/body1/div96/#text0 -inserted #document/html0/body1/div96/#comment1 -inserted #document/html0/body1/#comment97 +inserted #document/html0/body1/div97 inserted #document/html0/body1/div98 inserted #document/html0/body1/div99 -inserted #document/html0/body1/#comment100 +inserted #document/html0/body1/div99/#text0 +inserted #document/html0/body1/div100 inserted #document/html0/body1/div101 -inserted #document/html0/body1/div101/#text0 -inserted #document/html0/body1/div101/#comment1 -inserted #document/html0/body1/#comment102 +inserted #document/html0/body1/div102 +inserted #document/html0/body1/div102/#text0 inserted #document/html0/body1/div103 inserted #document/html0/body1/div104 -inserted #document/html0/body1/#comment105 +inserted #document/html0/body1/div105 +inserted #document/html0/body1/div105/#text0 inserted #document/html0/body1/div106 -inserted #document/html0/body1/div106/#text0 -inserted #document/html0/body1/div106/#comment1 -inserted #document/html0/body1/#comment107 +inserted #document/html0/body1/div107 inserted #document/html0/body1/div108 +inserted #document/html0/body1/div108/#text0 inserted #document/html0/body1/div109 -inserted #document/html0/body1/#comment110 +inserted #document/html0/body1/div110 inserted #document/html0/body1/div111 inserted #document/html0/body1/div111/#text0 -inserted #document/html0/body1/div111/#comment1 -inserted #document/html0/body1/#comment112 +inserted #document/html0/body1/div112 inserted #document/html0/body1/div113 inserted #document/html0/body1/div114 -inserted #document/html0/body1/#comment115 +inserted #document/html0/body1/div114/#text0 +inserted #document/html0/body1/div115 inserted #document/html0/body1/div116 -inserted #document/html0/body1/div116/#text0 -inserted #document/html0/body1/div116/#comment1 -inserted #document/html0/body1/#comment117 +inserted #document/html0/body1/div117 +inserted #document/html0/body1/div117/#text0 inserted #document/html0/body1/div118 inserted #document/html0/body1/div119 -inserted #document/html0/body1/#comment120 +inserted #document/html0/body1/div120 +inserted #document/html0/body1/div120/#text0 inserted #document/html0/body1/div121 -inserted #document/html0/body1/div121/#text0 -inserted #document/html0/body1/div121/#comment1 -inserted #document/html0/body1/#comment122 +inserted #document/html0/body1/div122 inserted #document/html0/body1/div123 +inserted #document/html0/body1/div123/#text0 inserted #document/html0/body1/div124 -inserted #document/html0/body1/#comment125 +inserted #document/html0/body1/div125 inserted #document/html0/body1/div126 inserted #document/html0/body1/div126/#text0 -inserted #document/html0/body1/div126/#comment1 -inserted #document/html0/body1/#comment127 +inserted #document/html0/body1/div127 inserted #document/html0/body1/div128 inserted #document/html0/body1/div129 -inserted #document/html0/body1/#comment130 +inserted #document/html0/body1/div129/#text0 +inserted #document/html0/body1/div130 inserted #document/html0/body1/div131 -inserted #document/html0/body1/div131/#text0 -inserted #document/html0/body1/div131/#comment1 -inserted #document/html0/body1/#comment132 +inserted #document/html0/body1/div132 +inserted #document/html0/body1/div132/#text0 inserted #document/html0/body1/div133 inserted #document/html0/body1/div134 -inserted #document/html0/body1/#comment135 +inserted #document/html0/body1/div135 +inserted #document/html0/body1/div135/#text0 inserted #document/html0/body1/div136 -inserted #document/html0/body1/div136/#text0 -inserted #document/html0/body1/div136/#comment1 -inserted #document/html0/body1/#comment137 +inserted #document/html0/body1/div137 inserted #document/html0/body1/div138 +inserted #document/html0/body1/div138/#text0 inserted #document/html0/body1/div139 -inserted #document/html0/body1/#comment140 +inserted #document/html0/body1/div140 inserted #document/html0/body1/div141 inserted #document/html0/body1/div141/#text0 -inserted #document/html0/body1/div141/#comment1 -inserted #document/html0/body1/#comment142 +inserted #document/html0/body1/div142 inserted #document/html0/body1/div143 inserted #document/html0/body1/div144 -inserted #document/html0/body1/#comment145 +inserted #document/html0/body1/div144/#text0 +inserted #document/html0/body1/div145 inserted #document/html0/body1/div146 -inserted #document/html0/body1/div146/#text0 -inserted #document/html0/body1/div146/#comment1 -inserted #document/html0/body1/#comment147 +inserted #document/html0/body1/div147 +inserted #document/html0/body1/div147/#text0 inserted #document/html0/body1/div148 inserted #document/html0/body1/div149 -inserted #document/html0/body1/#comment150 +inserted #document/html0/body1/div150 +inserted #document/html0/body1/div150/#text0 inserted #document/html0/body1/div151 -inserted #document/html0/body1/div151/#text0 -inserted #document/html0/body1/div151/#comment1 -inserted #document/html0/body1/#comment152 +inserted #document/html0/body1/div152 inserted #document/html0/body1/div153 +inserted #document/html0/body1/div153/#text0 inserted #document/html0/body1/div154 -inserted #document/html0/body1/#comment155 +inserted #document/html0/body1/div155 inserted #document/html0/body1/div156 inserted #document/html0/body1/div156/#text0 -inserted #document/html0/body1/div156/#comment1 -inserted #document/html0/body1/#comment157 +inserted #document/html0/body1/div157 inserted #document/html0/body1/div158 inserted #document/html0/body1/div159 -inserted #document/html0/body1/#comment160 +inserted #document/html0/body1/div159/#text0 +inserted #document/html0/body1/div160 inserted #document/html0/body1/div161 -inserted #document/html0/body1/div161/#text0 -inserted #document/html0/body1/div161/#comment1 -inserted #document/html0/body1/#comment162 +inserted #document/html0/body1/div162 +inserted #document/html0/body1/div162/#text0 inserted #document/html0/body1/div163 inserted #document/html0/body1/div164 -inserted #document/html0/body1/#comment165 +inserted #document/html0/body1/div165 +inserted #document/html0/body1/div165/#text0 inserted #document/html0/body1/div166 -inserted #document/html0/body1/div166/#text0 -inserted #document/html0/body1/div166/#comment1 -inserted #document/html0/body1/#comment167 +inserted #document/html0/body1/div167 inserted #document/html0/body1/div168 +inserted #document/html0/body1/div168/#text0 inserted #document/html0/body1/div169 -inserted #document/html0/body1/#comment170 +inserted #document/html0/body1/div170 inserted #document/html0/body1/div171 inserted #document/html0/body1/div171/#text0 -inserted #document/html0/body1/div171/#comment1 -inserted #document/html0/body1/#comment172 +inserted #document/html0/body1/div172 inserted #document/html0/body1/div173 inserted #document/html0/body1/div174 -inserted #document/html0/body1/#comment175 +inserted #document/html0/body1/div174/#text0 +inserted #document/html0/body1/div175 inserted #document/html0/body1/div176 -inserted #document/html0/body1/div176/#text0 -inserted #document/html0/body1/div176/#comment1 -inserted #document/html0/body1/#comment177 +inserted #document/html0/body1/div177 +inserted #document/html0/body1/div177/#text0 inserted #document/html0/body1/div178 inserted #document/html0/body1/div179 -inserted #document/html0/body1/#comment180 +inserted #document/html0/body1/div180 +inserted #document/html0/body1/div180/#text0 inserted #document/html0/body1/div181 -inserted #document/html0/body1/div181/#text0 -inserted #document/html0/body1/div181/#comment1 -inserted #document/html0/body1/#comment182 +inserted #document/html0/body1/div182 inserted #document/html0/body1/div183 +inserted #document/html0/body1/div183/#text0 inserted #document/html0/body1/div184 -inserted #document/html0/body1/#comment185 +inserted #document/html0/body1/div185 inserted #document/html0/body1/div186 inserted #document/html0/body1/div186/#text0 -inserted #document/html0/body1/div186/#comment1 -inserted #document/html0/body1/#comment187 +inserted #document/html0/body1/div187 inserted #document/html0/body1/div188 inserted #document/html0/body1/div189 -inserted #document/html0/body1/#comment190 +inserted #document/html0/body1/div189/#text0 +inserted #document/html0/body1/div190 inserted #document/html0/body1/div191 -inserted #document/html0/body1/div191/#text0 -inserted #document/html0/body1/div191/#comment1 -inserted #document/html0/body1/#comment192 +inserted #document/html0/body1/div192 +inserted #document/html0/body1/div192/#text0 inserted #document/html0/body1/div193 inserted #document/html0/body1/div194 -inserted #document/html0/body1/#comment195 +inserted #document/html0/body1/div195 +inserted #document/html0/body1/div195/#text0 inserted #document/html0/body1/div196 -inserted #document/html0/body1/div196/#text0 -inserted #document/html0/body1/div196/#comment1 -inserted #document/html0/body1/#comment197 -inserted #document/html0/body1/div198 -inserted #document/html0/body1/div199 -inserted #document/html0/body1/#comment200 -inserted #document/html0/body1/div201 -inserted #document/html0/body1/div201/#text0 -inserted #document/html0/body1/div201/#comment1 -inserted #document/html0/body1/#comment202 -inserted #document/html0/body1/div203 -inserted #document/html0/body1/div204 -inserted #document/html0/body1/#comment205 -inserted #document/html0/body1/div206 -inserted #document/html0/body1/div206/#text0 -inserted #document/html0/body1/div206/#comment1 -inserted #document/html0/body1/#comment207 -inserted #document/html0/body1/div208 -inserted #document/html0/body1/div209 -inserted #document/html0/body1/#comment210 -inserted #document/html0/body1/div211 -inserted #document/html0/body1/div211/#text0 -inserted #document/html0/body1/div211/#comment1 -inserted #document/html0/body1/#comment212 -inserted #document/html0/body1/div213 -inserted #document/html0/body1/div214 -inserted #document/html0/body1/#comment215 -inserted #document/html0/body1/div216 -inserted #document/html0/body1/div216/#text0 -inserted #document/html0/body1/div216/#comment1 -inserted #document/html0/body1/#comment217 -inserted #document/html0/body1/div218 -inserted #document/html0/body1/div219 -inserted #document/html0/body1/#comment220 -inserted #document/html0/body1/div221 -inserted #document/html0/body1/div221/#text0 -inserted #document/html0/body1/div221/#comment1 -inserted #document/html0/body1/#comment222 -inserted #document/html0/body1/div223 -inserted #document/html0/body1/div224 -inserted #document/html0/body1/#comment225 -inserted #document/html0/body1/div226 -inserted #document/html0/body1/div226/#text0 -inserted #document/html0/body1/div226/#comment1 -inserted #document/html0/body1/#comment227 -inserted #document/html0/body1/div228 -inserted #document/html0/body1/div229 -inserted #document/html0/body1/#comment230 -inserted #document/html0/body1/div231 -inserted #document/html0/body1/div231/#text0 -inserted #document/html0/body1/div231/#comment1 -inserted #document/html0/body1/#comment232 -inserted #document/html0/body1/div233 -inserted #document/html0/body1/div234 -inserted #document/html0/body1/#comment235 -inserted #document/html0/body1/div236 -inserted #document/html0/body1/div236/#text0 -inserted #document/html0/body1/div236/#comment1 -inserted #document/html0/body1/#comment237 -inserted #document/html0/body1/div238 -inserted #document/html0/body1/div239 -inserted #document/html0/body1/#comment240 -inserted #document/html0/body1/div241 -inserted #document/html0/body1/div241/#text0 -inserted #document/html0/body1/div241/#comment1 -inserted #document/html0/body1/#comment242 -inserted #document/html0/body1/div243 -inserted #document/html0/body1/div244 -inserted #document/html0/body1/#comment245 -inserted #document/html0/body1/div246 -inserted #document/html0/body1/div246/#text0 -inserted #document/html0/body1/div246/#comment1 -inserted #document/html0/body1/#comment247 -inserted #document/html0/body1/div248 -inserted #document/html0/body1/div249 -inserted #document/html0/body1/#comment250 -inserted #document/html0/body1/div251 -inserted #document/html0/body1/div251/#text0 -inserted #document/html0/body1/div251/#comment1 -inserted #document/html0/body1/#comment252 -inserted #document/html0/body1/div253 -inserted #document/html0/body1/div254 -inserted #document/html0/body1/#comment255 -inserted #document/html0/body1/div256 -inserted #document/html0/body1/div256/#text0 -inserted #document/html0/body1/div256/#comment1 -inserted #document/html0/body1/#comment257 -inserted #document/html0/body1/div258 -inserted #document/html0/body1/div259 -inserted #document/html0/body1/#comment260 -inserted #document/html0/body1/div261 -inserted #document/html0/body1/div261/#text0 -inserted #document/html0/body1/div261/#comment1 -inserted #document/html0/body1/#comment262 -inserted #document/html0/body1/div263 -inserted #document/html0/body1/div264 -inserted #document/html0/body1/#comment265 -inserted #document/html0/body1/div266 -inserted #document/html0/body1/div266/#text0 -inserted #document/html0/body1/div266/#comment1 -inserted #document/html0/body1/#comment267 -inserted #document/html0/body1/div268 -inserted #document/html0/body1/div269 -inserted #document/html0/body1/#comment270 -inserted #document/html0/body1/div271 -inserted #document/html0/body1/div271/#text0 -inserted #document/html0/body1/div271/#comment1 -inserted #document/html0/body1/#comment272 -inserted #document/html0/body1/div273 -inserted #document/html0/body1/div274 -inserted #document/html0/body1/#comment275 -inserted #document/html0/body1/div276 -inserted #document/html0/body1/div276/#text0 -inserted #document/html0/body1/div276/#comment1 -inserted #document/html0/body1/#comment277 -inserted #document/html0/body1/div278 -inserted #document/html0/body1/div279 -inserted #document/html0/body1/#comment280 -inserted #document/html0/body1/div281 -inserted #document/html0/body1/div281/#text0 -inserted #document/html0/body1/div281/#comment1 -inserted #document/html0/body1/#comment282 -inserted #document/html0/body1/div283 -inserted #document/html0/body1/div284 -inserted #document/html0/body1/#comment285 -inserted #document/html0/body1/div286 -inserted #document/html0/body1/div286/#text0 -inserted #document/html0/body1/div286/#comment1 -inserted #document/html0/body1/#comment287 -inserted #document/html0/body1/div288 -inserted #document/html0/body1/div289 -inserted #document/html0/body1/#comment290 -inserted #document/html0/body1/div291 -inserted #document/html0/body1/div291/#text0 -inserted #document/html0/body1/div291/#comment1 -inserted #document/html0/body1/#comment292 -inserted #document/html0/body1/div293 -inserted #document/html0/body1/div294 -inserted #document/html0/body1/#comment295 -inserted #document/html0/body1/div296 -inserted #document/html0/body1/div296/#text0 -inserted #document/html0/body1/div296/#comment1 -inserted #document/html0/body1/#comment297 -inserted #document/html0/body1/div298 -inserted #document/html0/body1/div299 -inserted #document/html0/body1/#comment300 -inserted #document/html0/body1/div301 -inserted #document/html0/body1/div301/#text0 -inserted #document/html0/body1/div301/#comment1 -inserted #document/html0/body1/#comment302 -inserted #document/html0/body1/div303 -inserted #document/html0/body1/div304 -inserted #document/html0/body1/#comment305 -inserted #document/html0/body1/#text306 -inserted #document/html0/body1/script307 -inserted #document/html0/body1/script307/#text0 +inserted #document/html0/body1/div197 +inserted #document/html0/body1/#text198 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/server.ts b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/server.ts index dfa1b2a631..276e39cff4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/server.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/server.ts @@ -1,7 +1,7 @@ import { createTemplate, fork, - tryPlaceholder, + tryContent, write, } from "@marko/runtime-tags/html"; @@ -9,15 +9,18 @@ import { resolveAfter } from "../../utils/resolve"; const renderer = () => { write("a"); - tryPlaceholder( - () => { + tryContent({ + content() { write("b"); fork(resolveAfter("c", 2), write); write("d"); }, - () => { - write("_A_"); - }, + placeholder: { + content() { + write("_A_"); + } + } + }, ); write("e"); fork(resolveAfter("f", 1), write); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/server.ts b/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/server.ts index 9cd2f42e89..c14c169e1b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/server.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/server.ts @@ -1,7 +1,7 @@ import { createTemplate, fork, - tryPlaceholder, + tryContent, write, } from "@marko/runtime-tags/html"; @@ -9,13 +9,16 @@ import { resolveAfter } from "../../utils/resolve"; const renderer = () => { write("a"); - tryPlaceholder( - () => { + tryContent({ + content() { write("b"); }, - () => { - write("_A_"); - }, + placeholder: { + content() { + write("_A_"); + } + } + }, ); write("c"); fork(resolveAfter("d", 1), write); diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/server.ts b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/server.ts index 7020798b1d..e39a123d9a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/server.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/server.ts @@ -1,7 +1,7 @@ import { createTemplate, fork, - tryPlaceholder, + tryContent, write, } from "@marko/runtime-tags/html"; @@ -9,25 +9,31 @@ import { resolveAfter } from "../../utils/resolve"; const renderer = () => { write("a"); - tryPlaceholder( - () => { + tryContent({ + content() { write("b"); fork(resolveAfter("c", 2), write); write("d"); - tryPlaceholder( - () => { + tryContent({ + content() { write("e"); fork(resolveAfter("f", 3), write); write("g"); }, - () => { - write("_A_"); - }, + placeholder: { + content() { + write("_A_"); + } + } + }, ); }, - () => { - write("_B_"); - }, + placeholder: { + content() { + write("_B_"); + } + } + }, ); write("h"); fork(resolveAfter("i", 1), write); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.expected/template.js new file mode 100644 index 0000000000..d2ad6d3c61 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/html.expected/template.js @@ -0,0 +1,21 @@ +import * as _$ from "@marko/runtime-tags/debug/html"; +const _renderer = /* @__PURE__ */_$.createRenderer((input, _tagVar) => { + const _scope0_id = _$.nextScopeId(); + _$.write("Before"); + _$.tryContent({ + content: _$.register(/* @__PURE__ */_$.createRenderer(() => { + const _scope2_id = _$.nextScopeId(); + _$.write(`Inside${_$.escapeXML((() => { + throw new Error("ERROR!"); + })())}`); + }), "__tests__/template.marko_2_renderer", _scope0_id), + catch: _$.attrTag({ + content: _$.register(/* @__PURE__ */_$.createRenderer(err => { + const _scope1_id = _$.nextScopeId(); + _$.write(`${_$.escapeXML(err.message)}${_$.markResumeNode(_scope1_id, "#text/0")}`); + }), "__tests__/template.marko_1_renderer", _scope0_id) + }) + }); + _$.write("After"); +}); +export default /* @__PURE__ */_$.createTemplate("__tests__/template.marko", _renderer); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr-sanitized.expected.md new file mode 100644 index 0000000000..a12b1e25f5 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr-sanitized.expected.md @@ -0,0 +1,4 @@ +# Render "End" +```html +BeforeERROR!After +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr.expected.md new file mode 100644 index 0000000000..d76df08425 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/__snapshots__/ssr.expected.md @@ -0,0 +1,30 @@ +# Write + BeforeERROR!After + + +# Render "End" +```html + + + + BeforeERROR! + + After + + + +``` + +# Mutations +``` +inserted #document/html0 +inserted #document/html0/head0 +inserted #document/html0/body1 +inserted #document/html0/body1/#text0 +inserted #document/html0/body1/#comment1 +inserted #document/html0/body1/#text2 +inserted #document/html0/body1/script3 +inserted #document/html0/body1/script3/#text0 +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/template.marko b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/template.marko new file mode 100644 index 0000000000..299270905a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/template.marko @@ -0,0 +1,8 @@ +-- Before +try + -- Inside + -- ${(() => { throw new Error("ERROR!") })()} + @catch|err| + -- ${err.message} + +-- After diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/test.ts b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/test.ts new file mode 100644 index 0000000000..7d0916d83c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/try-single-throw-sync/test.ts @@ -0,0 +1 @@ +export const skip_dom = true; diff --git a/packages/runtime-tags/src/html.ts b/packages/runtime-tags/src/html.ts index dc0768bfee..014c85dc1d 100644 --- a/packages/runtime-tags/src/html.ts +++ b/packages/runtime-tags/src/html.ts @@ -38,8 +38,7 @@ export { nodeRef, peekNextScope, register, - tryCatch, - tryPlaceholder, + tryContent, write, writeEffect, writeExistingScope, diff --git a/packages/runtime-tags/src/html/inlined-runtimes.ts b/packages/runtime-tags/src/html/inlined-runtimes.ts index f02b3019de..347d69a900 100644 --- a/packages/runtime-tags/src/html/inlined-runtimes.ts +++ b/packages/runtime-tags/src/html/inlined-runtimes.ts @@ -4,7 +4,7 @@ export const WALKER_RUNTIME_CODE = MARKO_DEBUG self[runtimeId] || ((renderId) => { let id, - markers = {}, + lookup = {}, visits = [], doc = document, walker = doc.createTreeWalker( @@ -14,7 +14,7 @@ export const WALKER_RUNTIME_CODE = MARKO_DEBUG op = (self[runtimeId][renderId] = { i: (renderId = runtimeId + renderId), d: doc, - l: markers, + l: lookup, v: visits, x() {}, w(node) { @@ -23,7 +23,7 @@ export const WALKER_RUNTIME_CODE = MARKO_DEBUG (op = (op = node.data) && !op.indexOf(renderId) && - ((markers[(id = op.slice(prefix + 1))] = node), op[prefix])), + ((lookup[(id = op.slice(prefix + 1))] = node), op[prefix])), id, node, ); diff --git a/packages/runtime-tags/src/html/writer.ts b/packages/runtime-tags/src/html/writer.ts index 4abd31d6a9..591fcf5d94 100644 --- a/packages/runtime-tags/src/html/writer.ts +++ b/packages/runtime-tags/src/html/writer.ts @@ -224,7 +224,36 @@ export function fork(promise: Promise | T, content: (value: T) => void) { ); } -export function tryPlaceholder(content: () => void, placeholder: () => void) { +export function tryContent(input: { + content?(): void; + placeholder?: { + content?(): void; + }; + catch?: { + content?(err: unknown): void; + }; +}) { + const content = input.content; + + if (content) { + const catchContent = input.catch?.content; + const placeholderContent = input.placeholder?.content; + if (catchContent) { + tryCatch( + placeholderContent + ? () => tryPlaceholder(content, placeholderContent) + : content, + catchContent, + ); + } else if (placeholderContent) { + tryPlaceholder(content, placeholderContent); + } else { + content(); + } + } +} + +function tryPlaceholder(content: () => void, placeholder: () => void) { const chunk = $chunk; const { boundary } = chunk; const body = new Chunk(boundary, null, chunk.context); @@ -239,10 +268,7 @@ export function tryPlaceholder(content: () => void, placeholder: () => void) { chunk.placeholderRender = placeholder; } -export function tryCatch( - content: () => void, - catchContent: (err: unknown) => void, -) { +function tryCatch(content: () => void, catchContent: (err: unknown) => void) { const chunk = $chunk; const { boundary } = chunk; const { state } = boundary; diff --git a/packages/runtime-tags/src/translator/core/define.ts b/packages/runtime-tags/src/translator/core/define.ts index 869ca9e7e1..092da21831 100644 --- a/packages/runtime-tags/src/translator/core/define.ts +++ b/packages/runtime-tags/src/translator/core/define.ts @@ -2,6 +2,7 @@ import { types as t } from "@marko/compiler"; import { assertNoArgs, type Tag } from "@marko/compiler/babel-utils"; import { isOutputHTML } from "../util/marko-config"; +import { analyzeAttributeTags } from "../util/nested-attribute-tags"; import { BindingType, getAllTagReferenceNodes, @@ -35,6 +36,7 @@ export default { trackVarReferences(tag, BindingType.derived); // TODO: should determine if var bindings are nullable based on attrs. trackParamsReferences(tagBody, BindingType.param); + analyzeAttributeTags(tag); mergeReferences( getOrCreateSection(tag), tag.node, diff --git a/packages/runtime-tags/src/translator/core/index.ts b/packages/runtime-tags/src/translator/core/index.ts index 0b460482fb..8ce88937f7 100644 --- a/packages/runtime-tags/src/translator/core/index.ts +++ b/packages/runtime-tags/src/translator/core/index.ts @@ -22,6 +22,7 @@ import ScriptTag from "./script"; import ServerTag from "./server"; import StaticTag from "./static"; import StyleTag from "./style"; +import TryTag from "./try"; export default { taglibId: runtimeInfo.taglibId, @@ -50,4 +51,5 @@ export default { "": ServerTag, "": StaticTag, "