Skip to content

Commit

Permalink
[BUGFIX] Fix 'hasAttribute is not a function' when jQuery is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
josemarluedke committed May 30, 2019
1 parent 70bcd9f commit 597810e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,29 @@ if (jQueryDisabled) {
assert.ok(receivedEvent, 'click event was triggered');
assert.notOk(receivedEvent.originalEvent, 'event is not a jQuery.Event');
}

['@test native event on text node does not throw on hasAttribute [ISSUE #16730]'](assert) {
this.registerComponent('x-foo', {
ComponentClass: Component.extend({
actions: {
someAction() {},
},
}),
template: `<a id="inner" href="#" {{action 'someAction'}}>test</a>`,
});

this.render(`{{x-foo id="outer"}}`);

let node = this.$('#inner')[0].childNodes[0];

runTask(() => {
let event = document.createEvent('HTMLEvents');
event.initEvent('mousemove', true, true);
node.dispatchEvent(event);
});

assert.ok(true);
}
}
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ export default EmberObject.extend({
} else if (event.cancelBubble === true) {
break;
}
} else if (target.hasAttribute('data-ember-action')) {
} else if (
typeof target.hasAttribute === 'function' &&
target.hasAttribute('data-ember-action')
) {
if (actionHandler(target, event) === false) {
break;
}
Expand Down

0 comments on commit 597810e

Please sign in to comment.