Fix server side rendering

Fixes problem when window is undefined in the server.
This commit is contained in:
Germán M. Bravo 2017-03-30 16:13:41 -06:00 committed by GitHub
parent 764de40fe0
commit 6984de7927

View File

@ -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();