Skip to content

Commit ebcc6a8

Browse files
committed
fix: remove global document object
BREAKING CHANGES: The `document` object is no longer property of the `global` object. This may cause behavioral changes in some plugin that use the `document` object to determine if they're running in browser context. fixes #1144
1 parent 9a16ae4 commit ebcc6a8

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

Diff for: nativescript-angular/platform-common.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,12 @@ export class NativeScriptSanitizer extends Sanitizer {
6666
}
6767
}
6868

69-
// Add a fake polyfill for the document object
70-
(<any>global).document = (<any>global).document || {
71-
getElementById: () => { return undefined; }
72-
};
73-
74-
const doc = (<any>global).document;
75-
doc.body = Object.assign(doc.body || {}, {
76-
isOverride: true,
77-
});
78-
7969
export class NativeScriptDocument {
70+
// Required by the AnimationDriver
71+
public body: any = {
72+
isOverride: true,
73+
};
74+
8075
createElement(tag: string) {
8176
throw new Error("NativeScriptDocument is not DOM Document. There is no createElement() method.");
8277
}
@@ -85,7 +80,7 @@ export class NativeScriptDocument {
8580
export const COMMON_PROVIDERS = [
8681
defaultPageFactoryProvider,
8782
{ provide: Sanitizer, useClass: NativeScriptSanitizer, deps: [] },
88-
{ provide: DOCUMENT, useValue: doc },
83+
{ provide: DOCUMENT, useClass: NativeScriptDocument, deps: [] },
8984
];
9085

9186
export class NativeScriptPlatformRef extends PlatformRef {

0 commit comments

Comments
 (0)