Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 0077d3e

Browse files
Splaktarjelbourn
authored andcommitted
fix(gesture): check if navigator is defined before accessing userAgent (#11755)
fixes a build error when using `angular/material-tools` Fixes #11751
1 parent f5535f8 commit 0077d3e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/core/services/gesture/gesture.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ var lastLabelClickPos = null;
1717
// Used to attach event listeners once when multiple ng-apps are running.
1818
var isInitialized = false;
1919

20-
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
21-
var isIos = userAgent.match(/ipad|iphone|ipod/i);
22-
var isAndroid = userAgent.match(/android/i);
20+
// Support material-tools builds.
21+
if (window.navigator) {
22+
var userAgent = window.navigator.userAgent || window.navigator.vendor || window.opera;
23+
var isIos = userAgent.match(/ipad|iphone|ipod/i);
24+
var isAndroid = userAgent.match(/android/i);
25+
}
2326

2427
/**
2528
* @ngdoc module

0 commit comments

Comments
 (0)