in .fire always set calling flag back to false (#1573)

pull/1587/head
Conduitry 7 years ago
parent 7774c6d92a
commit 39930dcbcc

@ -47,9 +47,12 @@ export function fire(eventName, data) {
var handler = handlers[i]; var handler = handlers[i];
if (!handler.__calling) { if (!handler.__calling) {
handler.__calling = true; try {
handler.call(this, data); handler.__calling = true;
handler.__calling = false; handler.call(this, data);
} finally {
handler.__calling = false;
}
} }
} }
} }

@ -0,0 +1,23 @@
export default {
test(assert, component) {
const events = [];
component.on('foo', (shouldThrow) => {
events.push(shouldThrow);
if (shouldThrow) {
throw new Error();
}
});
component.fire('foo', false);
assert.equal(events.toString(), 'false');
let threw = false;
try {
component.fire('foo', true);
} catch (err) {
threw = true;
}
assert.equal(threw, true);
assert.equal(events.toString(), 'false,true');
component.fire('foo', false);
assert.equal(events.toString(), 'false,true,false');
},
};
Loading…
Cancel
Save