refactor: set parentNode property to ViewBase (#5134)

Setter:
You can set a '_templateParent' by setting node.parentNode. This won't
affect the native parent of the node.
Getter:
Returns '_templateParent', if set, or the native parent otherwise.
Reason:
This will help us remove that abstraction from nativescript-angular as
it matches the DOM Nodes API name.
This commit is contained in:
Stanimira Vlaeva
2017-12-07 07:09:30 -08:00
committed by GitHub
parent 8973a6febd
commit f04b5eecd5
2 changed files with 14 additions and 0 deletions

View File

@@ -157,6 +157,11 @@ export abstract class ViewBase extends Observable {
*/
public readonly parent: ViewBase;
/**
* Gets the template parent or the native parent. Sets the template parent.
*/
public parentNode: ViewBase;
/**
* Gets or sets the id for this view.
*/

View File

@@ -149,6 +149,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
private _style: Style;
private _isLoaded: boolean;
private _visualState: string;
private _templateParent: ViewBase;
private __nativeView: any;
// private _disableNativeViewRecycling: boolean;
public domNode: dnm.DOMNode;
@@ -221,6 +222,14 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
this._style = new Style(this);
}
get parentNode() {
return this._templateParent || this.parent;
}
set parentNode(node: ViewBase) {
this._templateParent = node;
}
get nativeView(): any {
// this._disableNativeViewRecycling = true;
return this.nativeViewProtected;