Skip to content

Commit

Permalink
fix(ngTouch): check if tapElement.blur is a function
Browse files Browse the repository at this point in the history
On IE Edge and apparently old Firefox mobile (see angular#13272),
SVG elements do not have a blur function
  • Loading branch information
Narretz committed Dec 1, 2016
1 parent 4cd0512 commit 77302ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ngTouch/directive/ngClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ var ngTouchClickDirectiveFactory = ['$parse', '$timeout', '$rootElement',
// Blur the focused element (the button, probably) before firing the callback.
// This doesn't work perfectly on Android Chrome, but seems to work elsewhere.
// I couldn't get anything to work reliably on Android Chrome.
if (tapElement) {
if (tapElement && angular.isFunction(tapElement.blur)) {
tapElement.blur();
}

Expand Down
11 changes: 11 additions & 0 deletions test/ngTouch/directive/ngClickSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,17 @@ describe('ngClick (touch)', function() {

expect(blurSpy).toHaveBeenCalled();
});

it('should not complain when blur is not a function', function() {
otherElement.blur = null;
touch(otherElement, 10, 10);

time = 500;
expect(function() {
click(label, 10, 10);
}).not.toThrow();
});

});
});

Expand Down

0 comments on commit 77302ac

Please sign in to comment.