customevent.html revision eab87f0881fdf3e80c2a1af9224c50f0bf033644
194N/A logExclude: {Dom: true, Selector: true, Node: true, attribute: true, base: true, event: true, widget: true}
194N/A button.set("disabled", false);
194N/A var testEventTarget = new Y.Test.Case({
194N/A name: "Event.Target tests",
194N/A O.prototype = {
194N/A // pass configuration info into Event.Target with the following
194N/A Y.Assert.isTrue(this instanceof O);
194N/A Y.Assert.isTrue(arg1 === 1);
194N/A Y.Assert.isTrue(arg2 === 2);
194N/A Y.Assert.isTrue(fired);
194N/A Y.Assert.areEqual(1, arg1);
194N/A Y.Assert.areEqual(2, arg2);
194N/A arguments.callee.superclass.constructor.apply(this, arguments);
194N/A Y.Assert.isTrue(this instanceof Base);
194N/A Y.Assert.isTrue(arg1 === 1);
194N/A Y.Assert.isTrue(arg2 === 2);
194N/A Y.Assert.isTrue(fired);
194N/A O.prototype = {
194N/A // pass configuration info into Event.Target with the following
o.on('testPrefix', function(e, arg1, arg2) {
Y.Assert.isTrue(this instanceof O);
o.on('prefix:testPrefix', function(e, arg1, arg2) {
Y.Assert.isTrue(this instanceof O);
o.fire('testPrefix', { foo: 'afoo' }, 1, 2);
Y.Assert.isTrue(fired1);
// Y.Assert.isTrue(fired2);
o.fire('prefix:testPrefix', { foo: 'afoo' }, 1, 2);
Y.Assert.isTrue(fired1);
Y.Assert.isTrue(fired2);
Y.on('handle, test:event', function() {
Y.fire('test:event');
Y.Assert.isTrue(fired1);
Y.Assert.isFalse(fired2);
Y.detach('handle, test:event');
Y.on('handle, test:event', function() {
Y.fire('test:event');
Y.Assert.isFalse(fired1);
Y.Assert.isTrue(fired2);
Y.detach('handle,test:event');
Y.after('handle, test:event', function() {
Y.Assert.isTrue(fired1);
Y.on('handle|test:event', function() {
Y.Assert.isFalse(fired2);
Y.fire('test:event');
Y.detach('handle,test:event');
Y.fire('test:event');
Y.Assert.isFalse(fired1);
Y.Assert.isFalse(fired2);
Y.Assert.isTrue(fired2);
Y.Assert.isFalse(fired1);
var o = new Y2.EventTarget({
// Y2.after('p:e', f1).on('p:e', f2).on('p:e2', f3).on('detach, p:e', f4).detach('detach, p:e').fire('p:e').fire('p:e2');
o.after('e', f1).on('foo:e', f2).on('foo:e2', f3).on('detach, e', f4).detach('detach,e').fire('foo:e').fire('e2').on('pre:e', f5).fire('pre:e');
Y.Assert.isTrue(fired2); // verifies chaining, on/after order, and accepting the prefix in the event name
Y.Assert.isTrue(fired3); // verifies no interaction between events, and prefix manipulation
Y.Assert.isFalse(fired4); // verifies detach works (regardless of spaces after comma)
Y.Assert.isTrue(fired5); // verifies custom prefix
Y.Test.Runner.add(testEventTarget);