Skip to content

Commit 77302ac

Browse files
committed
fix(ngTouch): check if tapElement.blur is a function
On IE Edge and apparently old Firefox mobile (see angular#13272), SVG elements do not have a blur function
1 parent 4cd0512 commit 77302ac

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/ngTouch/directive/ngClick.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ var ngTouchClickDirectiveFactory = ['$parse', '$timeout', '$rootElement',
257257
// Blur the focused element (the button, probably) before firing the callback.
258258
// This doesn't work perfectly on Android Chrome, but seems to work elsewhere.
259259
// I couldn't get anything to work reliably on Android Chrome.
260-
if (tapElement) {
260+
if (tapElement && angular.isFunction(tapElement.blur)) {
261261
tapElement.blur();
262262
}
263263

test/ngTouch/directive/ngClickSpec.js

+11
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,17 @@ describe('ngClick (touch)', function() {
608608

609609
expect(blurSpy).toHaveBeenCalled();
610610
});
611+
612+
it('should not complain when blur is not a function', function() {
613+
otherElement.blur = null;
614+
touch(otherElement, 10, 10);
615+
616+
time = 500;
617+
expect(function() {
618+
click(label, 10, 10);
619+
}).not.toThrow();
620+
});
621+
611622
});
612623
});
613624

0 commit comments

Comments
 (0)