Skip to content

Commit

Permalink
fix: components not always initializing inside client-reorder await (#…
Browse files Browse the repository at this point in the history
…1566)

(cherry picked from commit 28b3b7f)
  • Loading branch information
DylanPiercey committed May 19, 2020
1 parent 0a227d0 commit da31ead
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Expand Up @@ -46,6 +46,7 @@ module.exports = function(input, out) {

function handleAwait(awaitInfo) {
awaitInfo.out
.on("___toString", out.emit.bind(out, "___toString"))
.on("finish", function(result) {
if (!global._afRuntime) {
asyncOut.script(clientReorder.getCode());
Expand Down
@@ -1,7 +1,22 @@
$ var promise = new Promise(resolve => setTimeout(resolve, 100));
<await(promise) client-reorder>
<div key="div0"/>
<app-child key="child0"/>

<await(new Promise(resolve => setTimeout(resolve, 100))) client-reorder>
<@then>
<div key="div"/>
<app-child key="child"/>
<div key="div1"/>
<app-child key="child1"/>

<await(new Promise(resolve => setTimeout(resolve, 200)))>
<@then>
<div key="div2"/>
<app-child key="child2"/>
</@then>
</await>

<div key="div3"/>
<app-child key="child3"/>
</@then>
</await>
</await>

<div key="div4"/>
<app-child key="child4"/>
@@ -1,7 +1,9 @@
var expect = require("chai").expect;

it("should initialize components correctly across async boundaries", function(done) {
expect(window.component.getEl("div")).to.not.equal(undefined);
expect(window.component.getComponent("child")).to.not.equal(undefined);
for (let i = 0; i <= 4; i++) {
expect(window.component.getEl(`div${i}`)).to.not.equal(undefined);
expect(window.component.getComponent(`child${i}`)).to.not.equal(undefined);
}
done();
});

0 comments on commit da31ead

Please sign in to comment.