Skip to content

Commit

Permalink
feat: make nativescript identify as browser in angular (#136)
Browse files Browse the repository at this point in the history
This enables all the browser features like `@defer`, `afterRender` and `afterNextRender`, which are integral parts of new updates (including the angular router in the future)

BREAKING CHANGES:

Identifying as browser can have minor impact on existing libraries that use that to manipulate the DOM. So far, the usage inside angular itself is minimal enough that it shouldn't impact apps other than enabling previously mentioned features.
  • Loading branch information
edusperoni authored Jul 17, 2024
1 parent 16bfffb commit c49fb86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Angular"
],
"dependencies": {
"@nativescript/zone-js": "^3.0.0"
"@nativescript/zone-js": "^3.0.4"
},
"sideEffects": [
"**/nativescript-angular-polyfills.mjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/src/lib/platform-nativescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type, Injector, CompilerOptions, PlatformRef, NgModuleFactory, NgModuleRef, EventEmitter, Sanitizer, InjectionToken, StaticProvider, createPlatformFactory, platformCore } from '@angular/core';
import { Type, Injector, CompilerOptions, PlatformRef, NgModuleFactory, NgModuleRef, EventEmitter, Sanitizer, InjectionToken, StaticProvider, createPlatformFactory, platformCore, PLATFORM_ID } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { NativeScriptPlatformRefProxy } from './platform-ref';
import { AppHostView } from './app-host-view';
Expand Down Expand Up @@ -31,7 +31,7 @@ export class NativeScriptDocument {
}
}

export const COMMON_PROVIDERS = [defaultPageFactoryProvider, { provide: Sanitizer, useClass: NativeScriptSanitizer, deps: [] }, { provide: DOCUMENT, useClass: NativeScriptDocument, deps: [] }];
export const COMMON_PROVIDERS = [defaultPageFactoryProvider, { provide: Sanitizer, useClass: NativeScriptSanitizer, deps: [] }, { provide: DOCUMENT, useClass: NativeScriptDocument, deps: [] }, { provide: PLATFORM_ID, useValue: 'browser' }];

export const platformNativeScript = createPlatformFactory(platformCore, 'nativescriptDynamic', COMMON_PROVIDERS);

Expand Down

0 comments on commit c49fb86

Please sign in to comment.