Skip to content

Commit

Permalink
[spike] trying to further simplify action event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinJoyce committed Jan 24, 2017
1 parent 7e177ec commit e39b79e
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions packages/ember-views/lib/system/event_dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,29 +220,18 @@ export default EmberObject.extend({
rootElement.on(`${event}.ember`, '[data-ember-action]', evt => {
let attributes = evt.currentTarget.attributes;
let attributeCount = attributes.length;
let actions = [];

for (let i = 0; i < attributeCount; i++) {
let attr = attributes.item(i);
let attrName = attr.name;

if (attrName.indexOf('data-ember-action-') === 0) {
actions = actions.concat(ActionManager.registeredActions[attr.value]);
}
}

// We have to check for actions here since in some cases, jQuery will trigger
// an event on `removeChild` (i.e. focusout) after we've already torn down the
// action handlers for the view.
if (actions.length === 0) {
return;
}

for (let index = 0; index < actions.length; index++) {
let action = actions[index];
//TODO: GJ: why does `registeredActions` contains arrays? are they always of length 1?
let action = ActionManager.registeredActions[attr.value][0];

if (action && action.eventName === eventName) {
return action.handler(evt);
if (action && action.eventName === eventName) {
action.handler(evt);
}
}
}
});
Expand Down

0 comments on commit e39b79e

Please sign in to comment.