b8fd9d997e
See #28391. git-svn-id: https://develop.svn.wordpress.org/trunk@28768 602fd350-edb4-49c9-b593-d223f7449a82
47 lines
1.0 KiB
JavaScript
47 lines
1.0 KiB
JavaScript
module("tinymce.util.Observable");
|
|
|
|
test("Event bubbling/removed state", function() {
|
|
var lastName, lastState, data = '';
|
|
|
|
function Class(parentObj) {
|
|
this.toggleNativeEvent = function(name, state) {
|
|
lastName = name;
|
|
lastState = state;
|
|
};
|
|
|
|
this.parent = function() {
|
|
return parentObj;
|
|
};
|
|
}
|
|
|
|
tinymce.util.Tools.extend(Class.prototype, tinymce.util.Observable);
|
|
|
|
var inst1 = new Class();
|
|
|
|
inst1.on('click', function() { data += 'a'; });
|
|
strictEqual(lastName, 'click');
|
|
strictEqual(lastState, true);
|
|
|
|
lastName = lastState = null;
|
|
inst1.on('click', function() { data += 'b'; });
|
|
strictEqual(lastName, null);
|
|
strictEqual(lastState, null);
|
|
|
|
var inst2 = new Class(inst1);
|
|
inst2.on('click', function() { data += 'c'; });
|
|
|
|
inst2.fire('click');
|
|
strictEqual(data, 'cab');
|
|
|
|
inst2.on('click', function(e) { e.stopPropagation(); });
|
|
|
|
inst2.fire('click');
|
|
strictEqual(data, 'cabc');
|
|
|
|
inst1.on('remove', function() { data += 'r'; });
|
|
inst1.removed = true;
|
|
inst1.fire('click');
|
|
inst1.fire('remove');
|
|
strictEqual(data, 'cabcr');
|
|
});
|