Skip to content

Commit

Permalink
[BUGFIX lts] Fix 'hasAttribute is not a function' when jQuery is disa…
Browse files Browse the repository at this point in the history
…bled (#18064)

[BUGFIX lts] Fix 'hasAttribute is not a function' when jQuery is disabled
  • Loading branch information
rwjblue authored May 30, 2019
2 parents 70bcd9f + 597810e commit a5af490
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 a5af490

Please sign in to comment.