Skip to content

Commit 023768a

Browse files
committed
fix: invalid walks string with static placeholder with surrounding text node
1 parent bf6b75b commit 023768a

File tree

14 files changed

+343
-7
lines changed

14 files changed

+343
-7
lines changed

.changeset/shaggy-books-cheer.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 incorrect walks string generated when static placeholder text used with adjacent text node.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"vars": {
3+
"props": {
4+
"$_$": "t",
5+
"$init": "o",
6+
"$$count_effect": "m",
7+
"$$count": "a"
8+
}
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Render
2+
```html
3+
= 0
4+
<button>
5+
Inc
6+
</button>
7+
```
8+
9+
10+
# Render
11+
```js
12+
container.querySelector("button").click();
13+
```
14+
```html
15+
= 1
16+
<button>
17+
Inc
18+
</button>
19+
```
20+
21+
22+
# Render
23+
```js
24+
container.querySelector("button").click();
25+
```
26+
```html
27+
= 2
28+
<button>
29+
Inc
30+
</button>
31+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Render
2+
```html
3+
= 0
4+
<button>
5+
Inc
6+
</button>
7+
```
8+
9+
# Mutations
10+
```
11+
INSERT #text0, #text1, button
12+
```
13+
14+
# Render
15+
```js
16+
container.querySelector("button").click();
17+
```
18+
```html
19+
= 1
20+
<button>
21+
Inc
22+
</button>
23+
```
24+
25+
# Mutations
26+
```
27+
UPDATE #text1 "0" => "1"
28+
```
29+
30+
# Render
31+
```js
32+
container.querySelector("button").click();
33+
```
34+
```html
35+
= 2
36+
<button>
37+
Inc
38+
</button>
39+
```
40+
41+
# Mutations
42+
```
43+
UPDATE #text1 "1" => "2"
44+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// size: 120 (min) 102 (brotli)
2+
const $count_effect = _$.effect("a0", ($scope, { 2: count }) =>
3+
_$.on($scope[1], "click", function () {
4+
$count($scope, count + 1);
5+
}),
6+
),
7+
$count = _$.state(2, ($scope, count) => {
8+
(_$.data($scope[0], count), $count_effect($scope));
9+
});
10+
init();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const $template = "= <!><button>Inc</button>";
2+
export const $walks = /* over(1), replace, over(1), get, over(1) */"b%b b";
3+
import * as _$ from "@marko/runtime-tags/debug/dom";
4+
const $count_effect = _$.effect("__tests__/template.marko_0_count", ($scope, {
5+
count
6+
}) => _$.on($scope["#button/1"], "click", function () {
7+
$count($scope, count + 1), count;
8+
}));
9+
const $count = /* @__PURE__ */_$.state("count/2", ($scope, count) => {
10+
_$.data($scope["#text/0"], count);
11+
$count_effect($scope);
12+
});
13+
export function $setup($scope) {
14+
$count($scope, 0);
15+
}
16+
export default /* @__PURE__ */_$.createTemplate("__tests__/template.marko", $template, $walks, $setup);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as _$ from "@marko/runtime-tags/debug/html";
2+
export default _$.createTemplate("__tests__/template.marko", input => {
3+
const $scope0_id = _$.nextScopeId();
4+
let count = 0;
5+
_$.write(`= <!>${_$.escapeXML(count)}${_$.markResumeNode($scope0_id, "#text/0")}<button>Inc</button>${_$.markResumeNode($scope0_id, "#button/1")}`);
6+
_$.writeEffect($scope0_id, "__tests__/template.marko_0_count");
7+
_$.writeScope($scope0_id, {
8+
count
9+
}, "__tests__/template.marko", 0, {
10+
count: "1:5"
11+
});
12+
_$.resumeClosestBranch($scope0_id);
13+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Render
2+
```html
3+
= 0
4+
<button>
5+
Inc
6+
</button>
7+
```
8+
9+
10+
# Render
11+
```js
12+
container.querySelector("button").click();
13+
```
14+
```html
15+
= 1
16+
<button>
17+
Inc
18+
</button>
19+
```
20+
21+
22+
# Render
23+
```js
24+
container.querySelector("button").click();
25+
```
26+
```html
27+
= 2
28+
<button>
29+
Inc
30+
</button>
31+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Render
2+
```html
3+
<html>
4+
<head />
5+
<body>
6+
=
7+
<!---->
8+
0
9+
<!--M_*1 #text/0-->
10+
<button>
11+
Inc
12+
</button>
13+
<!--M_*1 #button/1-->
14+
<script>
15+
WALKER_RUNTIME("M")("_");M._.r=[_=&gt;(_.a=[0,{count:0}]),"__tests__/template.marko_0_count",1];M._.w()
16+
</script>
17+
</body>
18+
</html>
19+
```
20+
21+
22+
# Render
23+
```js
24+
container.querySelector("button").click();
25+
```
26+
```html
27+
<html>
28+
<head />
29+
<body>
30+
=
31+
<!---->
32+
1
33+
<!--M_*1 #text/0-->
34+
<button>
35+
Inc
36+
</button>
37+
<!--M_*1 #button/1-->
38+
<script>
39+
WALKER_RUNTIME("M")("_");M._.r=[_=&gt;(_.a=[0,{count:0}]),"__tests__/template.marko_0_count",1];M._.w()
40+
</script>
41+
</body>
42+
</html>
43+
```
44+
45+
# Mutations
46+
```
47+
UPDATE html/body/#text1 "0" => "1"
48+
```
49+
50+
# Render
51+
```js
52+
container.querySelector("button").click();
53+
```
54+
```html
55+
<html>
56+
<head />
57+
<body>
58+
=
59+
<!---->
60+
2
61+
<!--M_*1 #text/0-->
62+
<button>
63+
Inc
64+
</button>
65+
<!--M_*1 #button/1-->
66+
<script>
67+
WALKER_RUNTIME("M")("_");M._.r=[_=&gt;(_.a=[0,{count:0}]),"__tests__/template.marko_0_count",1];M._.w()
68+
</script>
69+
</body>
70+
</html>
71+
```
72+
73+
# Mutations
74+
```
75+
UPDATE html/body/#text1 "1" => "2"
76+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Render End
2+
```html
3+
= 0
4+
<button>
5+
Inc
6+
</button>
7+
```

0 commit comments

Comments
 (0)