diff --git a/doc/base_api.md b/doc/base_api.md index 6e4fb9d3..1ec60d30 100644 --- a/doc/base_api.md +++ b/doc/base_api.md @@ -170,29 +170,6 @@ this.after('initialize', function() { }); ``` -Example of `handler` being a string that maps events to other events. This is -useful for proxying browser events to more meaningful custom events. - -```js -this.on('click', 'uiComponentClick'); -``` - -Example of `handler` being an object that maps events to other events. - -```js -this.attributes({ - menuItemSelector: '.menuItem', - saveButtonSelector: '#save' -}); - -this.after('initialize', function() { - this.on('click', { - menuItemSelector: 'uiMenuItemClick', - saveButtonSelector: 'uiSaveButtonClick' - }); -}); -``` - ## this.off([selector,] eventType [, handler]) diff --git a/lib/base.js b/lib/base.js index 8bac3f22..2e3dd0b6 100644 --- a/lib/base.js +++ b/lib/base.js @@ -109,12 +109,6 @@ define( }, this); } - function proxyEventTo(targetEvent) { - return function(e, data) { - $(e.target).trigger(targetEvent, data); - }; - } - function withBase() { // delegate trigger, bind and unbind to an element @@ -174,8 +168,6 @@ define( originalCb = utils.delegate( this.resolveDelegateRules(origin) ); - } else if (typeof origin == 'string') { - originalCb = proxyEventTo(origin); } else { originalCb = origin; } @@ -255,7 +247,7 @@ define( if (!(r in this.attr)) { throw new Error('Component "' + this.toString() + '" wants to listen on "' + r + '" but no such attribute was defined.'); } - rules[this.attr[r]] = (typeof ruleInfo[r] == 'string') ? proxyEventTo(ruleInfo[r]) : ruleInfo[r]; + rules[this.attr[r]] = ruleInfo[r]; }, this); return rules; diff --git a/test/spec/events_spec.js b/test/spec/events_spec.js index df904e70..e5a39276 100644 --- a/test/spec/events_spec.js +++ b/test/spec/events_spec.js @@ -101,40 +101,6 @@ define(['lib/component', 'lib/registry'], function (defineComponent, registry) { expect(spy2).toHaveBeenCalled(); }); - it('proxy from one to another when declared using "on" with a string', function () { - var instance = (new Component).initialize(window.outerDiv); - var data = {actor: 'Brent Spiner'}; - - // Declare an event proxy from 'sourceEvent' → 'targetEvent' - instance.on('sourceEvent', 'targetEvent'); - - var spy = jasmine.createSpy(); - instance.on('targetEvent', spy); - - instance.trigger('sourceEvent', data); - - expect(spy).toHaveBeenCalled(); - expect(spy.mostRecentCall.args[1]).toEqual(data); - }); - - it('proxy from one to another when declared using "on" with an object', function () { - var instance = (new Component).initialize(window.outerDiv, {'innerDiv': 'div'}); - var data = {actor: 'Brent Spiner'}; - - // Declare an event proxy from 'sourceEvent' → 'targetEvent' - instance.on('sourceEvent', { - 'innerDiv': 'targetEvent' - }); - - var spy = jasmine.createSpy(); - instance.on(window.innerDiv, 'targetEvent', spy); - - instance.trigger(window.innerDiv, 'sourceEvent', data); - - expect(spy).toHaveBeenCalled(); - expect(spy.mostRecentCall.args[1]).toEqual(data); - }); - it('unbinds listeners using "off"', function () { var instance1 = (new Component).initialize(window.outerDiv);