mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
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:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user