Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion nativescript-angular/platform-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export class NativeScriptSanitizer extends Sanitizer {
}
}

// Add a fake polyfill for the document object
(<any>global).document = (<any>global).document || {};
const doc = (<any>global).document;
doc.body = Object.assign((doc.body || {}), {
isOverride: true,
});

export class NativeScriptDocument {
createElement(tag: string) {
throw new Error("NativeScriptDocument is not DOM Document. There is no createElement() method.");
Expand All @@ -71,7 +78,7 @@ export class NativeScriptDocument {
export const COMMON_PROVIDERS = [
defaultPageFactoryProvider,
{ provide: Sanitizer, useClass: NativeScriptSanitizer, deps: [] },
{ provide: DOCUMENT, useClass: NativeScriptDocument, deps: [] },
{ provide: DOCUMENT, useValue: doc },
];

export class NativeScriptPlatformRef extends PlatformRef {
Expand Down
12 changes: 0 additions & 12 deletions nativescript-angular/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from "@angular/platform-browser-dynamic";

import {
DOCUMENT,
ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS as INTERNAL_BROWSER_PLATFORM_PROVIDERS
} from "@angular/platform-browser";

Expand All @@ -32,13 +31,6 @@ import {
StaticProvider,
} from "@angular/core";

// Add a fake polyfill for the document object
(<any>global).document = (<any>global).document || {};
const doc = (<any>global).document;
doc.body = Object.assign((doc.body || {}), {
isOverride: true,
});

// Work around a TS bug requiring an imports of
// InjectionToken, ViewEncapsulation and MissingTranslationStrategy
// without using them
Expand Down Expand Up @@ -67,10 +59,6 @@ export const NS_COMPILER_PROVIDERS: StaticProvider[] = [
},
multi: true
},
{
provide: DOCUMENT,
useValue: doc,
},
];

// Dynamic platform
Expand Down