Merge pull request #483 from annez/check-typeof-window

Move to check typeof for window for different envs
This commit is contained in:
Faisal Salman 2021-03-14 01:08:33 +07:00 committed by GitHub
commit 70a586d4b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -819,7 +819,7 @@
return new UAParser(uastring, extensions).getResult(); return new UAParser(uastring, extensions).getResult();
} }
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); var ua = uastring || ((typeof window !== 'undefined' && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
var rgxmap = extensions ? util.extend(regexes, extensions) : regexes; var rgxmap = extensions ? util.extend(regexes, extensions) : regexes;
this.getBrowser = function () { this.getBrowser = function () {
@ -915,7 +915,7 @@
define(function () { define(function () {
return UAParser; return UAParser;
}); });
} else if (window) { } else if (typeof window !== 'undefined') {
// browser env // browser env
window.UAParser = UAParser; window.UAParser = UAParser;
} }
@ -926,7 +926,7 @@
// In AMD env the global scope should be kept clean, but jQuery is an exception. // In AMD env the global scope should be kept clean, but jQuery is an exception.
// jQuery always exports to global scope, unless jQuery.noConflict(true) is used, // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
// and we should catch that. // and we should catch that.
var $ = window && (window.jQuery || window.Zepto); var $ = typeof window !== 'undefined' && (window.jQuery || window.Zepto);
if ($ && !$.ua) { if ($ && !$.ua) {
var parser = new UAParser(); var parser = new UAParser();
$.ua = parser.getResult(); $.ua = parser.getResult();