Skip to content

Commit c1d752c

Browse files
committed
fix: async issues
1 parent 4e289af commit c1d752c

File tree

28 files changed

+434
-139
lines changed

28 files changed

+434
-139
lines changed

.changeset/ripe-pandas-do.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 where client side placeholders were not clearing batched effects, causing extra execution.

.changeset/spotty-trees-design.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 moving @placeholder/@catch content when the replacement range was not yet flushed.

.sizes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{
88
"name": "*",
99
"total": {
10-
"min": 19362,
11-
"brotli": 7336
10+
"min": 19377,
11+
"brotli": 7348
1212
}
1313
},
1414
{

.sizes/dom.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 19362 (min) 7336 (brotli)
1+
// size: 19377 (min) 7348 (brotli)
22
var empty = [],
33
rest = Symbol();
44
function attrTag(attrs) {
@@ -1206,8 +1206,11 @@ function _await(nodeAccessor, renderer) {
12061206
tryWithPlaceholder.h.parentNode,
12071207
placeholderBranch.h,
12081208
),
1209-
removeAndDestroyBranch(placeholderBranch)),
1210-
tryWithPlaceholder.H && runEffects(tryWithPlaceholder.H, !0));
1209+
removeAndDestroyBranch(placeholderBranch)));
1210+
let pendingEffects2 = tryWithPlaceholder.H;
1211+
pendingEffects2 &&
1212+
((tryWithPlaceholder.H = []),
1213+
runEffects(pendingEffects2, !0));
12111214
}
12121215
},
12131216
-1,

packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr.expected.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ INSERT html/body/script0
111111
INSERT html/body/script0/#text
112112
REMOVE html/head/style after html/body/div
113113
INSERT html/head/style
114+
REMOVE t after html/body/div
114115
INSERT t
115116
INSERT html/body/div/div/div
116117
INSERT html/body/div/div/div/#comment0
@@ -125,23 +126,17 @@ INSERT t
125126
INSERT #comment
126127
INSERT html/body/script1
127128
INSERT html/body/script1/#text
128-
REMOVE html/body/div/div/div in t
129-
REMOVE #comment in t
130-
INSERT html/body/div/div/div
131129
REMOVE t after html/body/script0
132130
REMOVE #text after #comment
133131
REMOVE #comment after html/body/div/div/#comment0
134-
REMOVE html/body/div/div/div in t
135132
REMOVE #comment after html/body/div/div/#comment0
136133
INSERT html/body/div/div/div
137-
REMOVE t after html/body/div
134+
REMOVE t after html/body/script0
138135
INSERT t
139136
INSERT html/body/script2
140137
INSERT html/body/script2/#text
141-
REMOVE #comment in t
142138
REMOVE t after html/body/script1
143139
REMOVE #text after #comment
144140
REMOVE #comment after html/body/div/div/div/div/#comment0
145141
REMOVE #comment after html/body/div/div/div/div/#comment0
146-
REMOVE t after html/body/script0
147142
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"vars": {
3+
"props": {
4+
"$_": "e"
5+
}
6+
}
7+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Render
2+
3+
4+
# Render ASYNC
5+
```html
6+
Rejected B
7+
```
8+
9+
10+
# Render ASYNC
11+
```html
12+
<div>
13+
Resolved A: A Value
14+
</div>
15+
Rejected B
16+
```
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Render
2+
```html
3+
<!---->
4+
<!---->
5+
<!---->
6+
<!---->
7+
<!---->
8+
<!---->
9+
```
10+
11+
# Mutations
12+
```
13+
INSERT #comment0, #comment1, #text0, #comment2, #comment3, #text1, #comment4, #comment5
14+
```
15+
16+
# Render ASYNC
17+
```html
18+
<!---->
19+
<!---->
20+
<!---->
21+
Rejected B
22+
<!---->
23+
```
24+
25+
# Mutations
26+
```
27+
INSERT #text1
28+
REMOVE #comment after #text1
29+
REMOVE #text after #text1
30+
REMOVE #comment after #text1
31+
```
32+
33+
# Render ASYNC
34+
```html
35+
<!---->
36+
<!---->
37+
<div>
38+
Resolved A: A Value
39+
</div>
40+
<!---->
41+
Rejected B
42+
<!---->
43+
```
44+
45+
# Mutations
46+
```
47+
INSERT div
48+
REMOVE #text after div
49+
UPDATE div/#text1 "" => "A Value"
50+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// size: 118 (min) 67 (brotli)
2+
(_._enable_catch(),
3+
_._enable_catch(),
4+
_._content_resume("a0", "Rejected B", "b"),
5+
_._content_resume("a1", "Rejected A", "b"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
export const $template = "<!><!><!><!>";
2+
export const $walks = /* over(1), replace, over(1), replace, over(2) */"b%b%c";
3+
import { resolveAfter, rejectAfter } from "../../utils/resolve";
4+
import * as _ from "@marko/runtime-tags/debug/dom";
5+
_._enable_catch();
6+
_._enable_catch();
7+
const $await_content2__v = /* @__PURE__ */_._const("v", ($scope, v) => _._text($scope["#text/0"], v));
8+
const $await_content2__$params = /* @__PURE__ */_._const("$params3", ($scope, $params3) => $await_content2__v($scope, $params3[0]));
9+
const $await_content2 = /* @__PURE__ */_._content_branch("<div>Resolved B: <!></div>", /* next(1), over(1), replace, out(1) */"Db%l", 0, $await_content2__$params);
10+
const $catch_content2 = _._content_resume("__tests__/template.marko_5_content", "Rejected B", /* over(1) */"b");
11+
const $try_content2__await = /* @__PURE__ */_._await("#text/0", $await_content2);
12+
const $try_content2__setup = $scope => {
13+
$try_content2__await($scope, rejectAfter(new Error("rejected b"), 1));
14+
};
15+
const $try_content2 = /* @__PURE__ */_._content_branch("<!><!><!>", /* over(1), replace, over(2) */"b%c", $try_content2__setup);
16+
const $await_content__v = /* @__PURE__ */_._const("v", ($scope, v) => _._text($scope["#text/0"], v));
17+
const $await_content__$params = /* @__PURE__ */_._const("$params2", ($scope, $params2) => $await_content__v($scope, $params2[0]));
18+
const $await_content = /* @__PURE__ */_._content_branch("<div>Resolved A: <!></div>", /* next(1), over(1), replace, out(1) */"Db%l", 0, $await_content__$params);
19+
const $catch_content = _._content_resume("__tests__/template.marko_2_content", "Rejected A", /* over(1) */"b");
20+
const $try_content__await = /* @__PURE__ */_._await("#text/0", $await_content);
21+
const $try_content__setup = $scope => {
22+
$try_content__await($scope, resolveAfter("A Value", 2));
23+
};
24+
const $try_content = /* @__PURE__ */_._content_branch("<!><!><!>", /* over(1), replace, over(2) */"b%c", $try_content__setup);
25+
const $try = /* @__PURE__ */_._try("#text/0", $try_content);
26+
const $try2 = /* @__PURE__ */_._try("#text/1", $try_content2);
27+
export function $setup($scope) {
28+
$try($scope, {
29+
catch: _.attrTag({
30+
content: $catch_content($scope)
31+
})
32+
});
33+
$try2($scope, {
34+
catch: _.attrTag({
35+
content: $catch_content2($scope)
36+
})
37+
});
38+
}
39+
export default /* @__PURE__ */_._template("__tests__/template.marko", $template, $walks, $setup);

0 commit comments

Comments
 (0)