mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Forward error events from nested out of order async outs (#1275)
* Forward error events from nested out of order async outs
This commit is contained in:
parent
e5f5149b58
commit
a85230075f
@ -466,7 +466,10 @@ var proto = (AsyncStream.prototype = {
|
||||
},
|
||||
|
||||
createOut: function() {
|
||||
return new AsyncStream(this.global);
|
||||
var newOut = new AsyncStream(this.global);
|
||||
// Forward error events to the parent out.
|
||||
newOut.on("error", this.emit.bind(this, "error"));
|
||||
return newOut;
|
||||
},
|
||||
|
||||
element: function(tagName, elementAttrs, openTagOnly) {
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
<div>
|
||||
<await(input.userPromise) client-reorder>
|
||||
<@then|user|>Hello ${user.name}!</@then>
|
||||
</await>
|
||||
</div>
|
||||
@ -0,0 +1,24 @@
|
||||
var nodePath = require("path");
|
||||
|
||||
exports.check = function(marko, markoCompiler, expect, snapshot, done) {
|
||||
var template = marko.load(nodePath.join(__dirname, "template.marko"));
|
||||
var out = template.createOut();
|
||||
|
||||
template.render(
|
||||
{
|
||||
userPromise: new Promise((_, reject) => {
|
||||
setTimeout(function() {
|
||||
reject(new Error("User Promise Rejected Error"));
|
||||
}, 10);
|
||||
})
|
||||
},
|
||||
out
|
||||
);
|
||||
|
||||
out.on("error", err => {
|
||||
expect(
|
||||
err.message.indexOf("User Promise Rejected Error") !== -1
|
||||
).to.equal(true);
|
||||
done();
|
||||
});
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user