Skip to content

Commit 1c750f3

Browse files
committed
refactor: provide fake polyfill for global.document
1 parent 925a624 commit 1c750f3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Diff for: nativescript-angular/animations/animations.module.ts

-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ import { NativeScriptModule } from "../nativescript.module";
1818
import { NativeScriptRendererFactory } from "../renderer";
1919
import { NativeScriptAnimationDriver } from "./animation-driver";
2020

21-
(<any>global).document = {
22-
body: {
23-
isOverride: true,
24-
}
25-
};
26-
2721
@Injectable()
2822
export class InjectableAnimationEngine extends AnimationEngine {
2923
constructor(driver: AnimationDriver, normalizer: AnimationStyleNormalizer) {

Diff for: nativescript-angular/platform.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ import {
3232
StaticProvider,
3333
} from "@angular/core";
3434

35+
// Add a fake polyfill for the document object
36+
(<any>global).document = (<any>global).document || {};
37+
const doc = (<any>global).document;
38+
doc.body = Object.assign((doc.body || {}), {
39+
isOverride: true,
40+
});
41+
3542
// Work around a TS bug requiring an imports of
3643
// InjectionToken, ViewEncapsulation and MissingTranslationStrategy
3744
// without using them
@@ -62,7 +69,7 @@ export const NS_COMPILER_PROVIDERS: StaticProvider[] = [
6269
},
6370
{
6471
provide: DOCUMENT,
65-
useValue: { body: { isOverride: true } },
72+
useValue: doc,
6673
},
6774
];
6875

0 commit comments

Comments
 (0)