mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Fix server side rendering
Fixes problem when window is undefined in the server.
This commit is contained in:
parent
764de40fe0
commit
6984de7927
@ -885,7 +885,7 @@
|
|||||||
define(function () {
|
define(function () {
|
||||||
return UAParser;
|
return UAParser;
|
||||||
});
|
});
|
||||||
} else {
|
} else if (window) {
|
||||||
// browser env
|
// browser env
|
||||||
window.UAParser = UAParser;
|
window.UAParser = UAParser;
|
||||||
}
|
}
|
||||||
@ -896,7 +896,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.jQuery || window.Zepto;
|
var $ = window && (window.jQuery || window.Zepto);
|
||||||
if (typeof $ !== UNDEF_TYPE) {
|
if (typeof $ !== UNDEF_TYPE) {
|
||||||
var parser = new UAParser();
|
var parser = new UAParser();
|
||||||
$.ua = parser.getResult();
|
$.ua = parser.getResult();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user