diff --git a/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/dom.expected.js b/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/dom.expected.js index 716654417..8b7ba5910 100644 --- a/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/dom.expected.js +++ b/packages/translator/src/__tests__/fixtures/basic-counter/__snapshots__/dom.expected.js @@ -7,7 +7,7 @@ function _hydrate_clickCount(clickCount = _read(2)) { const _onclick = function () { const clickCount = _read(2); - _queue(_apply_clickCount, 2, clickCount + 1); + _queue(_apply_clickCount, 0, clickCount + 1); }; function _apply_clickCount(clickCount) { diff --git a/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/dom.expected.js b/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/dom.expected.js index 5efebbe0b..0e3e0480b 100644 --- a/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/dom.expected.js +++ b/packages/translator/src/__tests__/fixtures/basic-nested-scope-for/__snapshots__/dom.expected.js @@ -15,7 +15,7 @@ function _applyWith_selected_num(selected = _readInOwner(4), num = _read(2)) { const _onclick = function () { const num = _read(2); - _queueInOwner(_apply_selected, 4, num); + _queueInOwner(_apply_selected, 0, num); }; function _apply_num(num) { @@ -31,11 +31,11 @@ function _apply_num(num) { } function _apply_selected2(selected = _readInOwner(4)) { - _queue(_applyWith_selected_num, 4); + _queue(_applyWith_selected_num, 2); } function _apply_selected(selected) { - if (_write(4, selected)) _queueForEach(0, _apply_selected2, 4); + if (_write(4, selected)) _queueForEach(0, _apply_selected2, 0); } function _apply() { diff --git a/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/dom.expected.js b/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/dom.expected.js index 05620e263..363d060a9 100644 --- a/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/dom.expected.js +++ b/packages/translator/src/__tests__/fixtures/basic-nested-scope-if/__snapshots__/dom.expected.js @@ -9,7 +9,7 @@ function _hydrate_clickCount(clickCount = _readInOwner(4)) { const _onclick = function () { const clickCount = _readInOwner(4); - _queueInOwner(_apply_clickCount, 4, clickCount + 1); + _queueInOwner(_apply_clickCount, 0, clickCount + 1); }; function _apply_clickCount2(clickCount = _readInOwner(4)) { @@ -24,7 +24,7 @@ function _apply_clickCount(clickCount) { if (_write(4, clickCount)) { _setConditionalRenderer(0, clickCount < 3 ? _if : null); - _queueInBranch(0, _if, _apply_clickCount2, 4); + _queueInBranch(0, _if, _apply_clickCount2, 0); } } diff --git a/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/dom.expected.js b/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/dom.expected.js index f791cac99..9d1762cab 100644 --- a/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/dom.expected.js +++ b/packages/translator/src/__tests__/fixtures/basic-push-pop-list/__snapshots__/dom.expected.js @@ -21,9 +21,9 @@ const _onclick = function () { // TODO: nested writes ([...items, id++]) don't work const nextId = id + 1; - _queue(_apply_id, 6, nextId); + _queue(_apply_id, 0, nextId); - _queue(_apply_items, 7, [...items, nextId]); + _queue(_apply_items, 1, [...items, nextId]); }; function _applyWith_id_items(id = _read(6), items = _read(7)) { @@ -35,7 +35,7 @@ function _applyWith_id_items(id = _read(6), items = _read(7)) { const _onclick2 = function () { const items = _read(7); - _queue(_apply_items, 7, items.slice(0, -1)); + _queue(_apply_items, 1, items.slice(0, -1)); }; function _apply_items(items) { @@ -46,12 +46,12 @@ function _apply_items(items) { _hydrate_items(); - _queue(_applyWith_id_items, 7); + _queue(_applyWith_id_items, 2); } } function _apply_id(id) { - if (_write(6, id)) _queue(_applyWith_id_items, 6); + if (_write(6, id)) _queue(_applyWith_id_items, 2); } function _apply() { diff --git a/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/dom.expected.js b/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/dom.expected.js index 28d56d4e9..ff9c3dd2e 100644 --- a/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/dom.expected.js +++ b/packages/translator/src/__tests__/fixtures/basic-toggle-show/__snapshots__/dom.expected.js @@ -9,7 +9,7 @@ function _hydrate_show(show = _read(5)) { const _onclick = function () { const show = _read(5); - _queue(_apply_show, 5, !show); + _queue(_apply_show, 0, !show); }; function _apply_show(show) { diff --git a/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/dom.expected.js b/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/dom.expected.js index e80794433..d0d51037d 100644 --- a/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/dom.expected.js +++ b/packages/translator/src/__tests__/fixtures/if-tag/__snapshots__/dom.expected.js @@ -19,19 +19,19 @@ function _applyWith_a_b(a = _read(12), b = _read(13)) { } function _apply_y(y) { - if (_write(15, y)) _queue(_applyWith_x_y, 15); + if (_write(15, y)) _queue(_applyWith_x_y, 5); } function _apply_x(x) { - if (_write(14, x)) _queue(_applyWith_x_y, 14); + if (_write(14, x)) _queue(_applyWith_x_y, 5); } function _apply_b(b) { - if (_write(13, b)) _queue(_applyWith_a_b, 13); + if (_write(13, b)) _queue(_applyWith_a_b, 4); } function _apply_a(a) { - if (_write(12, a)) _queue(_applyWith_a_b, 12); + if (_write(12, a)) _queue(_applyWith_a_b, 4); } export const template = "
"; diff --git a/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/dom.expected.js b/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/dom.expected.js index 17a685bec..5101cabb0 100644 --- a/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/dom.expected.js +++ b/packages/translator/src/__tests__/fixtures/let-tag/__snapshots__/dom.expected.js @@ -5,7 +5,7 @@ function _hydrateWith_x_y(x = _read(3), y = _read(4)) { } function _applyWith_x_y(x = _read(3), y = _read(4)) { - _write(5, _queue(_apply_x, 3, y = x + y)); + _write(5, _queue(_apply_x, 0, y = x + y)); _hydrateWith_x_y(); } @@ -14,7 +14,7 @@ function _apply_y(y) { if (_write(4, y)) { _data(2, y); - _queue(_applyWith_x_y, 4); + _queue(_applyWith_x_y, 2); } } @@ -22,7 +22,7 @@ function _apply_x(x) { if (_write(3, x)) { _data(1, x); - _queue(_applyWith_x_y, 3); + _queue(_applyWith_x_y, 2); } } diff --git a/packages/translator/src/core/condition/else-if.ts b/packages/translator/src/core/condition/else-if.ts index 9d747bc3e..81fa1fd40 100644 --- a/packages/translator/src/core/condition/else-if.ts +++ b/packages/translator/src/core/condition/else-if.ts @@ -1,7 +1,6 @@ import { types as t } from "@marko/compiler"; import { Tag, assertNoParams, assertNoVar } from "@marko/babel-utils"; -import { exitBranch, queueBranchBuilder } from "./if"; -import { setQueueBuilder } from "../../util/apply-hydrate"; +import { exitBranch } from "./if"; export default { translate: { @@ -35,8 +34,6 @@ export default { ); } } - - setQueueBuilder(tag, queueBranchBuilder); }, exit(tag) { exitBranch(tag); diff --git a/packages/translator/src/core/condition/else.ts b/packages/translator/src/core/condition/else.ts index eb9af2bf9..08534e734 100644 --- a/packages/translator/src/core/condition/else.ts +++ b/packages/translator/src/core/condition/else.ts @@ -1,7 +1,6 @@ import type { types as t } from "@marko/compiler"; import { Tag, assertNoParams, assertNoVar } from "@marko/babel-utils"; -import { setQueueBuilder } from "../../util/apply-hydrate"; -import { exitBranch, queueBranchBuilder } from "./if"; +import { exitBranch } from "./if"; export default { translate: { @@ -30,8 +29,6 @@ export default { ); } } - - setQueueBuilder(tag, queueBranchBuilder); }, exit(tag) { exitBranch(tag); diff --git a/packages/translator/src/core/condition/if.ts b/packages/translator/src/core/condition/if.ts index dc22c3ac3..ef0930373 100644 --- a/packages/translator/src/core/condition/if.ts +++ b/packages/translator/src/core/condition/if.ts @@ -3,11 +3,7 @@ import { Tag, assertNoParams, assertNoVar } from "@marko/babel-utils"; import * as writer from "../../util/writer"; import * as walks from "../../util/walks"; import * as sorted from "../../util/sorted-arr"; -import { - addStatement, - queueBuilder, - setQueueBuilder, -} from "../../util/apply-hydrate"; +import { addStatement, setQueueBuilder } from "../../util/apply-hydrate"; import { callRuntime } from "../../util/runtime"; import { isCoreTagName } from "../../util/is-core-tag"; import toFirstStatementOrBlock from "../../util/to-first-statement-or-block"; @@ -72,7 +68,6 @@ export default { walks.visit(tag, walks.WalkCodes.Replace); walks.enterShallow(tag); - setQueueBuilder(tag, queueBranchBuilder); if (isOutputHTML()) { writer.flushBefore(tag); } @@ -99,21 +94,6 @@ const BRANCHES_LOOKUP = new WeakMap< }[] >(); -export const queueBranchBuilder: queueBuilder = ( - binding, - functionIdentifier, - targetSectionId -) => { - const renderer = writer.getRenderer(targetSectionId); - return callRuntime( - "queueInBranch", - t.numericLiteral(0), - renderer, - functionIdentifier, - t.numericLiteral(binding.id) - ); -}; - export function exitBranch(tag: t.NodePath