Skip to content

Commit 23fc2fb

Browse files
committed
refactor: provide fake polyfill for global.document
1 parent 4154575 commit 23fc2fb

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
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

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ import {
3232
StaticProvider,
3333
} from "@angular/core";
3434

35-
// Work around a TS bug requiring an imports of
36-
// InjectionToken, ViewEncapsulation and MissingTranslationStrategy
37-
// without using them
38-
if ((<any>global).___TS_UNUSED) {
39-
(() => InjectionToken)();
40-
(() => ViewEncapsulation)();
41-
(() => MissingTranslationStrategy)();
42-
}
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+
});
4341

4442
// Register DOM adapter, if possible. Dynamic platform only!
4543
import "./dom-adapter";
@@ -62,7 +60,7 @@ export const NS_COMPILER_PROVIDERS: StaticProvider[] = [
6260
},
6361
{
6462
provide: DOCUMENT,
65-
useValue: { body: { isOverride: true } },
63+
useValue: doc,
6664
},
6765
];
6866

0 commit comments

Comments
 (0)