Skip to content

Commit 978e628

Browse files
committed
mount await blocks with siblings (#974), and unmount correctly (#975)
1 parent a6836bd commit 978e628

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/generators/dom/visitors/AwaitBlock.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function visitAwaitBlock(
6767
${old_block}.u();
6868
${old_block}.d();
6969
${await_block}.c();
70-
${await_block}.m(${anchor}.parentNode, ${anchor});
70+
${await_block}.m(${state.parentNode || `${anchor}.parentNode`}, ${anchor});
7171
}
7272
}
7373
@@ -142,6 +142,10 @@ export default function visitAwaitBlock(
142142
`);
143143
}
144144

145+
block.builders.unmount.addBlock(deindent`
146+
${await_block}.u();
147+
`);
148+
145149
block.builders.destroy.addBlock(deindent`
146150
${await_token} = null;
147151
${await_block}.d();

test/runtime/samples/await-then-catch-if/_config.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let fulfil;
22

3-
let thePromise = new Promise(f => {
3+
const thePromise = new Promise(f => {
44
fulfil = f;
55
});
66

@@ -35,9 +35,11 @@ export default {
3535
show: true
3636
});
3737

38-
assert.htmlEqual(target.innerHTML, `
39-
<p>the value is 42</p>
40-
`);
38+
return thePromise.then(() => {
39+
assert.htmlEqual(target.innerHTML, `
40+
<p>the value is 42</p>
41+
`);
42+
});
4143
});
4244
}
4345
};

0 commit comments

Comments
 (0)