Skip to content

Commit a34bfb9

Browse files
rturnqDylanPiercey
authored andcommitted
fix: serializer - ensure circular references of registered functions are all assigned
1 parent 280f4d3 commit a34bfb9

32 files changed

+644
-0
lines changed

.changeset/hungry-needles-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/runtime-tags": patch
3+
---
4+
5+
Fix serializer to ensure circular references to registered functions all all assigned
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"vars": {
3+
"props": {
4+
"$_": "t",
5+
"$init": "r",
6+
"$$z__OR__x__OR__setter": "e",
7+
"$$z": "o",
8+
"$$count": "n",
9+
"$$setCount__script": "m",
10+
"$$input_value__OR__setter": "s",
11+
"$$input_value": "u"
12+
}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Render
2+
```html
3+
<div>
4+
0
5+
</div>
6+
```
7+
8+
9+
# Render ASYNC
10+
```html
11+
<div>
12+
1
13+
</div>
14+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Render
2+
```html
3+
<div>
4+
0
5+
</div>
6+
```
7+
8+
# Mutations
9+
```
10+
INSERT div
11+
```
12+
13+
# Render ASYNC
14+
```html
15+
<div>
16+
1
17+
</div>
18+
```
19+
20+
# Mutations
21+
```
22+
UPDATE div/#text "0" => "1"
23+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const $template = "";
2+
export const $walks = "";
3+
export const $setup = () => {};
4+
import * as _ from "@marko/runtime-tags/debug/dom";
5+
const $input_value__OR__setter = /* @__PURE__ */_._or(5, $scope => {
6+
let {
7+
input_value,
8+
setter
9+
} = $scope;
10+
_._return($scope, (input_value, setter));
11+
});
12+
const $setter2 = /* @__PURE__ */_._const("setter", $input_value__OR__setter);
13+
export const $input_valueChange = /* @__PURE__ */_._const("input_valueChange", ($scope, input_valueChange) => $setter2($scope, {
14+
fn: $setter($scope)
15+
}));
16+
export const $input_value = /* @__PURE__ */_._const("input_value", $input_value__OR__setter);
17+
export const $input = /* @__PURE__ */_._const("input", ($scope, input) => {
18+
$input_valueChange($scope, input.valueChange);
19+
$input_value($scope, input.value);
20+
});
21+
function $setter({
22+
input_valueChange
23+
}) {
24+
return function () {
25+
input_valueChange(1);
26+
};
27+
}
28+
_._resume("__tests__/tags/setter.marko_0/setter", $setter);
29+
export default /* @__PURE__ */_._template("__tests__/tags/setter.marko", $template, $walks, $setup, $input);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// size: 298 (min) 192 (brotli)
2+
const $input_value__OR__setter = _._or(5, ($scope) => {
3+
let { 3: input_value, 4: setter } = $scope;
4+
_._return($scope, setter);
5+
}),
6+
$input_value = _._const(3, $input_value__OR__setter);
7+
_._resume("a0", function ({ 2: input_valueChange }) {
8+
return function () {
9+
input_valueChange(1);
10+
};
11+
});
12+
const $count = _._let(3, ($scope, count) => {
13+
($input_value($scope[0], count), _._text($scope[2], count));
14+
}),
15+
$setCount__script = _._script("b1", ({ 4: setCount }) => setCount.fn());
16+
(_._var_resume("b2", _._const(4, $setCount__script)),
17+
_._resume("b0", function ($scope) {
18+
return (_new_count) => {
19+
$count($scope, _new_count);
20+
};
21+
}),
22+
init());
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const $template = `${_setter_template}<div> </div>`;
2+
export const $walks = /* beginChildWithVar, _setter_walks, endChild, next(1), get, out(1) */`0${_setter_walks}&D l`;
3+
import * as _ from "@marko/runtime-tags/debug/dom";
4+
import { $setup as _setter, $input_value as _setter_input_value, $input_valueChange as _setter_input_valueChange, $template as _setter_template, $walks as _setter_walks } from "./tags/setter.marko";
5+
const $count = /* @__PURE__ */_._let("count/3", ($scope, count) => {
6+
_setter_input_value($scope["#childScope/0"], count);
7+
_._text($scope["#text/2"], count);
8+
});
9+
export function $setup($scope) {
10+
_._var($scope, "#childScope/0", $setCount);
11+
_setter($scope["#childScope/0"]);
12+
_setter_input_valueChange($scope["#childScope/0"], $valueChange($scope));
13+
$count($scope, 0);
14+
}
15+
const $setCount__script = _._script("__tests__/template.marko_0_setCount", ({
16+
setCount
17+
}) => setCount.fn());
18+
const $setCount = _._var_resume("__tests__/template.marko_0_setCount/var", /* @__PURE__ */_._const("setCount", $setCount__script));
19+
function $valueChange($scope) {
20+
return _new_count => {
21+
$count($scope, _new_count);
22+
};
23+
}
24+
_._resume("__tests__/template.marko_0/valueChange", $valueChange);
25+
export default /* @__PURE__ */_._template("__tests__/template.marko", $template, $walks, $setup);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as _ from "@marko/runtime-tags/debug/html";
2+
export default _._template("__tests__/tags/setter.marko", input => {
3+
const $scope0_reason = _._scope_reason();
4+
const $scope0_id = _._scope_id();
5+
const setter = {
6+
fn: _._resume(function () {
7+
input.valueChange(1);
8+
}, "__tests__/tags/setter.marko_0/setter", $scope0_id)
9+
};
10+
const $return = (input.value, setter);
11+
_._scope($scope0_id, {
12+
input_valueChange: input.valueChange,
13+
input_value: _._serialize_if($scope0_reason, /* input.valueChange */0) && input.value,
14+
setter: _._serialize_if($scope0_reason, /* input.value */1) && setter
15+
}, "__tests__/tags/setter.marko", 0, {
16+
input_valueChange: ["input.valueChange"],
17+
input_value: ["input.value"],
18+
setter: "1:8"
19+
});
20+
return $return;
21+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import _setter from "./tags/setter.marko";
2+
import * as _ from "@marko/runtime-tags/debug/html";
3+
export default _._template("__tests__/template.marko", input => {
4+
const $scope0_id = _._scope_id();
5+
let count = 0;
6+
const $childScope = _._peek_scope_id();
7+
_._set_serialize_reason({
8+
/* input.value */1: /* count */1
9+
});
10+
let setCount = _setter({
11+
value: count,
12+
valueChange: _._resume(_new_count => {
13+
count = _new_count;
14+
}, "__tests__/template.marko_0/valueChange", $scope0_id)
15+
});
16+
_._var($scope0_id, "#scopeOffset/1", $childScope, "__tests__/template.marko_0_setCount/var");
17+
_._html(`<div>${_._escape(count)}${_._el_resume($scope0_id, "#text/2")}</div>`);
18+
_._script($scope0_id, "__tests__/template.marko_0_setCount");
19+
_._scope($scope0_id, {
20+
setCount,
21+
"#childScope/0": _._existing_scope($childScope)
22+
}, "__tests__/template.marko", 0, {
23+
setCount: "2:9"
24+
});
25+
_._resume_branch($scope0_id);
26+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Render
2+
```html
3+
<div>
4+
0
5+
</div>
6+
```
7+
8+
9+
# Render ASYNC
10+
```html
11+
<div>
12+
1
13+
</div>
14+
```

0 commit comments

Comments
 (0)