Parcourir la source

Handle case where an environment may have set `document` to `null`.

Afshin Darian il y a 6 ans
Parent
commit
a24919355f

+ 1 - 1
packages/coreutils/src/poll.ts

@@ -246,7 +246,7 @@ export class Poll<T = any, U = any> implements IDisposable {
     const { max, min, variance } = this;
 
     // Reschedule without executing poll promise if application is hidden.
-    if (typeof document !== 'undefined' && document.hidden) {
+    if (typeof document !== 'undefined' && document && document.hidden) {
       this._resolve(poll, {
         interval: Private.jitter(this.interval, variance, min, max),
         payload: null,

+ 1 - 1
packages/coreutils/src/url.ts

@@ -17,7 +17,7 @@ export namespace URLExt {
    * @returns A URL object.
    */
   export function parse(url: string): IUrl {
-    if (typeof document !== 'undefined') {
+    if (typeof document !== 'undefined' && document) {
       let a = document.createElement('a');
       a.href = url;
       return a;

+ 1 - 1
packages/services/src/serverconnection.ts

@@ -260,7 +260,7 @@ namespace Private {
       authenticated = true;
       request.headers.append('Authorization', `token ${settings.token}`);
     }
-    if (typeof document !== 'undefined' && document.cookie) {
+    if (typeof document !== 'undefined' && document && document.cookie) {
       const xsrfToken = getCookie('_xsrf');
       if (xsrfToken !== undefined) {
         authenticated = true;