Skip to content

Commit e87ef68

Browse files
author
vakrilov
committed
fix: Router tracing does not work with webpack
1 parent 625759d commit e87ef68

File tree

3 files changed

+20
-34
lines changed

3 files changed

+20
-34
lines changed

Diff for: nativescript-angular/dom-adapter.ts

+19-31
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
/* tslint:disable */
22
import { Type } from "@angular/core";
3-
import { ɵDomAdapter } from "@angular/platform-browser";
3+
import { ɵDomAdapter, ɵsetRootDomAdapter } from "@angular/platform-browser";
44
import { rendererLog, isLogEnabled } from "./trace";
55

66
export class NativeScriptDomAdapter implements ɵDomAdapter {
77
static makeCurrent() {
8+
if (isLogEnabled()) {
9+
rendererLog("Setting root DOM adapter...");
10+
}
811

9-
// Don't register when bundling (likely AoT setup).
10-
if (!global.TNS_WEBPACK) {
11-
try {
12-
const privateAPI = global.require("@angular/platform-browser");
13-
const setRootDomAdapter = privateAPI.ɵsetRootDomAdapter;
14-
15-
if (isLogEnabled()) {
16-
rendererLog("Setting root DOM adapter...");
17-
}
18-
setRootDomAdapter(new NativeScriptDomAdapter());
19-
} catch (e) {
20-
if (isLogEnabled()) {
21-
rendererLog("@angular/platform-browser package not present. NOT setting root DOM adapter...");
22-
}
23-
}
24-
}
12+
ɵsetRootDomAdapter(new NativeScriptDomAdapter());
2513
}
2614

2715
hasProperty(_element: any, _name: string) {
@@ -44,8 +32,8 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
4432
logGroupEnd(): void {
4533
}
4634

47-
get attrToPropMap(): {[key: string]: string} { throw new Error("Not implemented!"); };
48-
set attrToPropMap(_value: {[key: string]: string}) { throw new Error("Not implemented!"); };
35+
get attrToPropMap(): { [key: string]: string } { throw new Error("Not implemented!"); };
36+
set attrToPropMap(_value: { [key: string]: string }) { throw new Error("Not implemented!"); };
4937

5038
public resourceLoaderType: Type<any> = null;
5139
setProperty(_el: Element, _name: string, _value: any): any /** TODO #9100 */ { throw new Error("Not implemented!") }
@@ -58,11 +46,11 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
5846
querySelector(_el: any /** TODO #9100 */, _selector: string): HTMLElement { throw new Error("Not implemented!") }
5947
querySelectorAll(_el: any /** TODO #9100 */, _selector: string): any[] { throw new Error("Not implemented!") }
6048
on(
61-
_el: any /** TODO #9100 */, _evt: any /** TODO #9100 */, _listener: any /** TODO #9100 */): any
49+
_el: any /** TODO #9100 */, _evt: any /** TODO #9100 */, _listener: any /** TODO #9100 */): any
6250
/** TODO #9100 */ { throw new Error("Not implemented!") }
6351
onAndCancel(
64-
_el: any /** TODO #9100 */, _evt: any /** TODO #9100 */,
65-
_listener: any /** TODO #9100 */): Function { throw new Error("Not implemented!") }
52+
_el: any /** TODO #9100 */, _evt: any /** TODO #9100 */,
53+
_listener: any /** TODO #9100 */): Function { throw new Error("Not implemented!") }
6654
dispatchEvent(_el: any /** TODO #9100 */, _evt: any /** TODO #9100 */): any
6755
/** TODO #9100 */ { throw new Error("Not implemented!") }
6856
createMouseEvent(_eventType: any /** TODO #9100 */): any { throw new Error("Not implemented!") }
@@ -88,8 +76,8 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
8876
removeChild(_el: any /** TODO #9100 */, _node: any /** TODO #9100 */): any
8977
/** TODO #9100 */ { throw new Error("Not implemented!") }
9078
replaceChild(
91-
_el: any /** TODO #9100 */, _newNode: any /** TODO #9100 */,
92-
_oldNode: any /** TODO #9100 */): any /** TODO #9100 */ { throw new Error("Not implemented!") }
79+
_el: any /** TODO #9100 */, _newNode: any /** TODO #9100 */,
80+
_oldNode: any /** TODO #9100 */): any /** TODO #9100 */ { throw new Error("Not implemented!") }
9381
remove(_el: any /** TODO #9100 */): Node { throw new Error("Not implemented!") }
9482
insertBefore(_el: any /** TODO #9100 */, _node: any /** TODO #9100 */): any
9583
/** TODO #9100 */ { throw new Error("Not implemented!") }
@@ -111,13 +99,13 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
11199
createElementNS(_ns: string, _tagName: string, _doc?: any /** TODO #9100 */): Element { throw new Error("Not implemented!") }
112100
createTextNode(_text: string, _doc?: any /** TODO #9100 */): Text { throw new Error("Not implemented!") }
113101
createScriptTag(_attrName: string, _attrValue: string, _doc?: any /** TODO #9100 */):
114-
HTMLElement { throw new Error("Not implemented!") }
102+
HTMLElement { throw new Error("Not implemented!") }
115103
createStyleElement(_css: string, _doc?: any /** TODO #9100 */): HTMLStyleElement { throw new Error("Not implemented!") }
116104
createShadowRoot(_el: any /** TODO #9100 */): any { throw new Error("Not implemented!") }
117105
getShadowRoot(_el: any /** TODO #9100 */): any { throw new Error("Not implemented!") }
118106
getHost(_el: any /** TODO #9100 */): any { throw new Error("Not implemented!") }
119107
getDistributedNodes(_el: any /** TODO #9100 */): Node[] { throw new Error("Not implemented!") }
120-
clone /*<T extends Node>*/ (_node: Node /*T*/): Node /*T*/ { throw new Error("Not implemented!") }
108+
clone /*<T extends Node>*/(_node: Node /*T*/): Node /*T*/ { throw new Error("Not implemented!") }
121109
getElementsByClassName(_element: any /** TODO #9100 */, _name: string): HTMLElement[] { throw new Error("Not implemented!") }
122110
getElementsByTagName(_element: any /** TODO #9100 */, _name: string): HTMLElement[] { throw new Error("Not implemented!") }
123111
classList(_element: any /** TODO #9100 */): any[] { throw new Error("Not implemented!") }
@@ -129,7 +117,7 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
129117
removeStyle(_element: any /** TODO #9100 */, _styleName: string): any /** TODO #9100 */ { throw new Error("Not implemented!") }
130118
getStyle(_element: any /** TODO #9100 */, _styleName: string): string { throw new Error("Not implemented!") }
131119
hasStyle(_element: any /** TODO #9100 */, _styleName: string, _styleValue?: string):
132-
boolean { throw new Error("Not implemented!") }
120+
boolean { throw new Error("Not implemented!") }
133121
tagName(_element: any /** TODO #9100 */): string { throw new Error("Not implemented!") }
134122
attributeMap(_element: any /** TODO #9100 */): Map<string, string> { throw new Error("Not implemented!") }
135123
hasAttribute(_element: any /** TODO #9100 */, _attribute: string): boolean { throw new Error("Not implemented!") }
@@ -139,7 +127,7 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
139127
setAttribute(_element: any /** TODO #9100 */, _name: string, _value: string): any
140128
/** TODO #9100 */ { throw new Error("Not implemented!") }
141129
setAttributeNS(_element: any /** TODO #9100 */, _ns: string, _name: string, _value: string):
142-
any /** TODO #9100 */ { throw new Error("Not implemented!") }
130+
any /** TODO #9100 */ { throw new Error("Not implemented!") }
143131
removeAttribute(_element: any /** TODO #9100 */, _attribute: string): any
144132
/** TODO #9100 */ { throw new Error("Not implemented!") }
145133
removeAttributeNS(_element: any /** TODO #9100 */, _ns: string, _attribute: string): any
@@ -158,8 +146,8 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
158146
isElementNode(_node: any /** TODO #9100 */): boolean { throw new Error("Not implemented!") }
159147
hasShadowRoot(_node: any /** TODO #9100 */): boolean { throw new Error("Not implemented!") }
160148
isShadowRoot(_node: any /** TODO #9100 */): boolean { throw new Error("Not implemented!") }
161-
importIntoDoc /*<T extends Node>*/ (_node: Node /*T*/): Node /*T*/ { throw new Error("Not implemented!") }
162-
adoptNode /*<T extends Node>*/ (_node: Node /*T*/): Node /*T*/ { throw new Error("Not implemented!") }
149+
importIntoDoc /*<T extends Node>*/(_node: Node /*T*/): Node /*T*/ { throw new Error("Not implemented!") }
150+
adoptNode /*<T extends Node>*/(_node: Node /*T*/): Node /*T*/ { throw new Error("Not implemented!") }
163151
getHref(_element: any /** TODO #9100 */): string { throw new Error("Not implemented!") }
164152
getEventKey(_event: any /** TODO #9100 */): string { throw new Error("Not implemented!") }
165153
resolveAndSetHref(_element: any /** TODO #9100 */, _baseUrl: string, _href: string): any
@@ -183,7 +171,7 @@ export class NativeScriptDomAdapter implements ɵDomAdapter {
183171
getTransitionEnd(): string { throw new Error("Not implemented!") }
184172
supportsAnimation(): boolean { throw new Error("Not implemented!") }
185173

186-
supportsCookies(): boolean { return false; }
174+
supportsCookies(): boolean { return false; }
187175
getCookie(_name: string): string { throw new Error("Not implemented!") }
188176
setCookie(_name: string, _value: string): any /** TODO #9100 */ { throw new Error("Not implemented!") }
189177
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import "./zone-js/dist/zone-nativescript";
66
import "./polyfills/array";
77
import "./polyfills/console";
88
import { profile, uptime } from "tns-core-modules/profiling";
9+
import "./dom-adapter";
910

1011
import {
1112
Type,

Diff for: nativescript-angular/platform.ts

-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ if ((<any>global).___TS_UNUSED) {
4040
(() => MissingTranslationStrategy)();
4141
}
4242

43-
// Register DOM adapter, if possible. Dynamic platform only!
44-
import "./dom-adapter";
45-
4643
import { NativeScriptElementSchemaRegistry } from "./schema-registry";
4744
import { FileSystemResourceLoader } from "./resource-loader";
4845

0 commit comments

Comments
 (0)