Skip to content

Commit 97e9ae8

Browse files
committed
fix: param only serialize reasons
1 parent 460f78e commit 97e9ae8

File tree

15 files changed

+448
-3
lines changed

15 files changed

+448
-3
lines changed

.changeset/wicked-cougars-raise.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 issue with invalid html compilation output when having param only serialize reasons.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"vars": {
3+
"props": {
4+
"$_": "t",
5+
"$init": "n",
6+
"$$define_content2__value__OR__call": "e",
7+
"$$define_content2__call": "_",
8+
"$$define_content2__value": "r",
9+
"$$define_content2__$params": "o",
10+
"$$define_content2__$temp": "c",
11+
"$$define_content__value__OR__call": "u",
12+
"$$define_content__call": "a",
13+
"$$define_content__value": "s",
14+
"$$define_content__$params": "m",
15+
"$$define_content__$temp": "i",
16+
"$$dynamicTag": "l",
17+
"$$Once__OR__clickOnceCount": "f",
18+
"$$clickOnceCount": "v",
19+
"$$dynamicTag2": "d",
20+
"$$Twice__OR__clickTwiceCount": "g",
21+
"$$clickTwiceCount": "k",
22+
"$$onClickOnce2__script": "p",
23+
"$$onClickOnce2": "x",
24+
"$$onClickTwice2__script": "y",
25+
"$$onClickTwice2": "b",
26+
"$$_return2": "h",
27+
"$$_return": "j",
28+
"$$onClickOnce": "q",
29+
"$$onClickTwice": "w",
30+
"$$define_content2__setup": "z",
31+
"$$define_content__setup": "A",
32+
"$$if_content__setup": "D",
33+
"$$if_content": "B",
34+
"$$if": "C",
35+
"$$x__script": "E",
36+
"$$x": "F"
37+
}
38+
}
39+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Render `{"message":"hello"}`
2+
3+
```html
4+
<div />
5+
<button>
6+
0
7+
</button>
8+
```
9+
10+
11+
# Render
12+
```js
13+
container.querySelector("button").click();
14+
```
15+
```html
16+
<div>
17+
<span>
18+
hello
19+
</span>
20+
</div>
21+
<button>
22+
1
23+
</button>
24+
```
25+
26+
27+
# Render
28+
```js
29+
container.querySelector("button").click();
30+
```
31+
```html
32+
<div>
33+
<span>
34+
hello
35+
</span>
36+
</div>
37+
<button>
38+
2
39+
</button>
40+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Render `{"message":"hello"}`
2+
3+
```html
4+
<div />
5+
<button>
6+
0
7+
</button>
8+
```
9+
10+
# Mutations
11+
```
12+
INSERT div, button
13+
```
14+
15+
# Render
16+
```js
17+
container.querySelector("button").click();
18+
```
19+
```html
20+
<div>
21+
<span>
22+
hello
23+
</span>
24+
</div>
25+
<button>
26+
1
27+
</button>
28+
```
29+
30+
# Mutations
31+
```
32+
UPDATE button/#text "0" => "1"
33+
INSERT div/span
34+
UPDATE div/span/#text " " => "hello"
35+
```
36+
37+
# Render
38+
```js
39+
container.querySelector("button").click();
40+
```
41+
```html
42+
<div>
43+
<span>
44+
hello
45+
</span>
46+
</div>
47+
<button>
48+
2
49+
</button>
50+
```
51+
52+
# Mutations
53+
```
54+
UPDATE button/#text "1" => "2"
55+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// size: 285 (min) 188 (brotli)
2+
const $if_content__setup = _._if_closure(7, 0, 0, ($scope, getMessage) =>
3+
_._text($scope[0], getMessage()),
4+
),
5+
$if_content = _._content_branch("<span> </span>", "D l", $if_content__setup),
6+
$if = _._if(0, $if_content),
7+
$x__script = _._script("a1", ($scope, { 6: x }) =>
8+
_._on($scope[1], "click", function () {
9+
$x($scope, ++x);
10+
}),
11+
),
12+
$x = _._let(6, ($scope, x) => {
13+
(_._text($scope[2], x), $if($scope, x ? 0 : 1), $x__script($scope));
14+
});
15+
(_._resume("a0", function ({ 5: input_message }) {
16+
return () => input_message;
17+
}),
18+
init());
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export const $template = "<div></div><button> </button>";
2+
export const $walks = /* get, over(1), get, next(1), get, out(1) */" b D l";
3+
import * as _ from "@marko/runtime-tags/debug/dom";
4+
const $if_content__getMessage = /* @__PURE__ */_._if_closure("getMessage", "#div/0", 0, ($scope, getMessage) => _._text($scope["#text/0"], getMessage()));
5+
const $if_content__setup = $if_content__getMessage;
6+
const $if_content = /* @__PURE__ */_._content_branch("<span> </span>", /* next(1), get, out(1) */"D l", $if_content__setup);
7+
const $if = /* @__PURE__ */_._if("#div/0", $if_content);
8+
const $x__script = _._script("__tests__/template.marko_0_x", ($scope, {
9+
x
10+
}) => _._on($scope["#button/1"], "click", function () {
11+
$x($scope, ++x);
12+
}));
13+
const $x = /* @__PURE__ */_._let("x/6", ($scope, x) => {
14+
_._text($scope["#text/2"], x);
15+
$if($scope, x ? 0 : 1);
16+
$x__script($scope);
17+
});
18+
export function $setup($scope) {
19+
$x($scope, 0);
20+
}
21+
const $getMessage2 = /* @__PURE__ */_._const("getMessage", $if_content__getMessage);
22+
export const $input_message = /* @__PURE__ */_._const("input_message", ($scope, input_message) => $getMessage2($scope, $getMessage($scope)));
23+
export const $input = /* @__PURE__ */_._const("input", ($scope, input) => $input_message($scope, input.message));
24+
function $getMessage({
25+
input_message
26+
}) {
27+
return () => input_message;
28+
}
29+
_._resume("__tests__/template.marko_0/getMessage", $getMessage);
30+
export default /* @__PURE__ */_._template("__tests__/template.marko", $template, $walks, $setup, $input);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as _ from "@marko/runtime-tags/debug/html";
2+
export default _._template("__tests__/template.marko", input => {
3+
const $serialize = _._get_serialize_reason();
4+
const $scope0_id = _._scope_id();
5+
let x = 0;
6+
const getMessage = _._resume(() => input.message, "__tests__/template.marko_0/getMessage", $scope0_id);
7+
_._html("<div>");
8+
_._if(() => {
9+
if (x) {
10+
const $scope1_id = _._scope_id();
11+
_._html(`<span>${_._escape(getMessage())}${_._el_resume($scope1_id, "#text/0", _._serialize_guard($serialize, /* input.message */0))}</span>`);
12+
_._scope($scope1_id, {
13+
_: _._serialize_if($serialize, /* input.message */0) && _._scope_with_id($scope0_id)
14+
}, "__tests__/template.marko", "4:4");
15+
return 0;
16+
}
17+
}, $scope0_id, "#div/0", 1, /* state: x */1, /* state: x */1, "</div>", 1);
18+
_._html(`<button>${_._escape(x)}${_._el_resume($scope0_id, "#text/2")}</button>${_._el_resume($scope0_id, "#button/1")}`);
19+
_._script($scope0_id, "__tests__/template.marko_0_x");
20+
_._scope($scope0_id, {
21+
input_message: input.message,
22+
x,
23+
getMessage
24+
}, "__tests__/template.marko", 0, {
25+
input_message: ["input.message"],
26+
x: "1:6",
27+
getMessage: "2:8"
28+
});
29+
_._resume_branch($scope0_id);
30+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Render `{"message":"hello"}`
2+
3+
```html
4+
<div />
5+
<button>
6+
0
7+
</button>
8+
```
9+
10+
11+
# Render
12+
```js
13+
container.querySelector("button").click();
14+
```
15+
```html
16+
<div>
17+
<span>
18+
hello
19+
</span>
20+
</div>
21+
<button>
22+
1
23+
</button>
24+
```
25+
26+
27+
# Render
28+
```js
29+
container.querySelector("button").click();
30+
```
31+
```html
32+
<div>
33+
<span>
34+
hello
35+
</span>
36+
</div>
37+
<button>
38+
2
39+
</button>
40+
```
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Render `{"message":"hello"}`
2+
3+
```html
4+
<html>
5+
<head />
6+
<body>
7+
<div>
8+
<!--M_}1 #div/0-->
9+
</div>
10+
<button>
11+
0
12+
<!--M_*1 #text/2-->
13+
</button>
14+
<!--M_*1 #button/1-->
15+
<script>
16+
WALKER_RUNTIME("M")("_");
17+
M._.r = [_ =&gt; (_.b = [0, _.a = {
18+
input_message: "hello",
19+
x: 0
20+
}], _.a.getMessage = _._[
21+
"__tests__/template.marko_0/getMessage"
22+
](_.a), _.b),
23+
"__tests__/template.marko_0_x",
24+
1
25+
];
26+
M._.w()
27+
</script>
28+
</body>
29+
</html>
30+
```
31+
32+
33+
# Render
34+
```js
35+
container.querySelector("button").click();
36+
```
37+
```html
38+
<html>
39+
<head />
40+
<body>
41+
<div>
42+
<!--M_}1 #div/0-->
43+
<span>
44+
hello
45+
</span>
46+
</div>
47+
<button>
48+
1
49+
<!--M_*1 #text/2-->
50+
</button>
51+
<!--M_*1 #button/1-->
52+
<script>
53+
WALKER_RUNTIME("M")("_");
54+
M._.r = [_ =&gt; (_.b = [0, _.a = {
55+
input_message: "hello",
56+
x: 0
57+
}], _.a.getMessage = _._[
58+
"__tests__/template.marko_0/getMessage"
59+
](_.a), _.b),
60+
"__tests__/template.marko_0_x",
61+
1
62+
];
63+
M._.w()
64+
</script>
65+
</body>
66+
</html>
67+
```
68+
69+
# Mutations
70+
```
71+
UPDATE html/body/button/#text "0" => "1"
72+
INSERT html/body/div/span
73+
UPDATE html/body/div/span/#text " " => "hello"
74+
```
75+
76+
# Render
77+
```js
78+
container.querySelector("button").click();
79+
```
80+
```html
81+
<html>
82+
<head />
83+
<body>
84+
<div>
85+
<!--M_}1 #div/0-->
86+
<span>
87+
hello
88+
</span>
89+
</div>
90+
<button>
91+
2
92+
<!--M_*1 #text/2-->
93+
</button>
94+
<!--M_*1 #button/1-->
95+
<script>
96+
WALKER_RUNTIME("M")("_");
97+
M._.r = [_ =&gt; (_.b = [0, _.a = {
98+
input_message: "hello",
99+
x: 0
100+
}], _.a.getMessage = _._[
101+
"__tests__/template.marko_0/getMessage"
102+
](_.a), _.b),
103+
"__tests__/template.marko_0_x",
104+
1
105+
];
106+
M._.w()
107+
</script>
108+
</body>
109+
</html>
110+
```
111+
112+
# Mutations
113+
```
114+
UPDATE html/body/button/#text "1" => "2"
115+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Render End
2+
```html
3+
<div />
4+
<button>
5+
0
6+
</button>
7+
```

0 commit comments

Comments
 (0)