Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngAria.ngClick): restrict preventDefault on space / enter to non-… #16680

Merged
merged 3 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ngAria/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
var keyCode = event.which || event.keyCode;

if (keyCode === 13 || keyCode === 32) {
// Prevent the default browser behavior (e.g. scrolling when pressing spacebar) ...
// If the event is triggered on a non-interactive element ...
if (nodeBlackList.indexOf(event.target.nodeName) === -1) {
// ... but only when the event is triggered by a non-interactive element
// ... prevent the default browser behavior (e.g. scrolling when pressing spacebar)
// See https://github.com/angular/angular.js/issues/16664
event.preventDefault();
}
Expand Down
6 changes: 1 addition & 5 deletions test/ngAria/ariaSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,7 @@ describe('$aria', function() {
they('should not prevent default keyboard action if an interactive $type element' +
'is nested inside ng-click', nodeBlackList, function(elementType) {
function createHTML(type) {
var html = '<' + type + '>';

if (type === 'INPUT' || 'TYPE' === 'A') return html;

return html + '</' + type + '>';
return '<' + type + '></' + type + '>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<input></input> is not correct, but will work nonetheless 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I simply removed it because the browsers don't care ;)

}

compileElement(
Expand Down