stop[Immediate]Propagation tests

This commit is contained in:
David Greenspan
2012-07-12 15:12:29 -07:00
parent deba0fb0f0
commit 9cea9aa205

View File

@@ -1363,7 +1363,7 @@ Tinytest.add("liveui - event handling", function(test) {
div.kill();
Meteor.flush();
// stopPropagationd doesn't prevent other event maps from
// stopPropagation doesn't prevent other event maps from
// handling same node
event_buf.length = 0;
div = OnscreenDiv(Meteor.ui.render(function() {
@@ -1372,7 +1372,7 @@ Tinytest.add("liveui - event handling", function(test) {
return '<span id="foozy" class="a b c">Hello</span>';
}, {events: eventmap("click .c"), event_data:event_buf});
}, {events: {"click .b": function(evt) {
event_buf.push("click .b"); evt.stopPropagation(); return false;}}});
event_buf.push("click .b"); evt.stopPropagation();}}});
}, {events: eventmap("click .a"), event_data:event_buf}));
clickElement(getid("foozy"));
test.equal(event_buf, ['click .c', 'click .b', 'click .a']);
@@ -1380,6 +1380,23 @@ Tinytest.add("liveui - event handling", function(test) {
div.kill();
Meteor.flush();
// stopImmediatePropagation DOES
event_buf.length = 0;
div = OnscreenDiv(Meteor.ui.render(function() {
return Meteor.ui.chunk(function() {
return Meteor.ui.chunk(function() {
return '<span id="foozy" class="a b c">Hello</span>';
}, {events: eventmap("click .c"), event_data:event_buf});
}, {events: {"click .b": function(evt) {
event_buf.push("click .b");
evt.stopImmediatePropagation();}}});
}, {events: eventmap("click .a"), event_data:event_buf}));
clickElement(getid("foozy"));
test.equal(event_buf, ['click .c', 'click .b']);
event_buf.length = 0;
div.kill();
Meteor.flush();
// bubbling continues even with DOM change
event_buf.length = 0;
R = ReactiveVar(true);