customevent.html revision eab87f0881fdf3e80c2a1af9224c50f0bf033644
919N/A logExclude: {Dom: true, Selector: true, Node: true, attribute: true, base: true, event: true, widget: true}
98N/A button.set("disabled", false);
98N/A var testEventTarget = new Y.Test.Case({
911N/A name: "Event.Target tests",
98N/A O.prototype = {
1097N/A // pass configuration info into Event.Target with the following
1018N/A Y.Assert.isTrue(this instanceof O);
1018N/A Y.Assert.isTrue(arg1 === 1);
1018N/A Y.Assert.isTrue(arg2 === 2);
o.fire('testAugment', { foo: 'afoo' }, 1, 2);
Y.Assert.isTrue(fired);
o.on('testAugment', function(e, arg1, arg2) {
Y.Assert.areEqual(1, arg1);
Y.Assert.areEqual(2, arg2);
o.fire('testAugment', 1, 2);
Y.log('Base constructor executed');
arguments.callee.superclass.constructor.apply(this, arguments);
Y.log('all your base...');
b.on('testExtend', function(arg1, arg2) {
Y.Assert.isTrue(this instanceof Base);
Y.Assert.isTrue(arg1 === 1);
Y.Assert.isTrue(arg2 === 2);
b.fire('testExtend', 1, 2);
Y.Assert.isTrue(fired);
this.id = id;
Y.log('O constructor executed ' + id);
O.prototype = {
Y.log('oOo');
// 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);