Content-Length: 273169 | pFad | http://github.com/NativeScript/NativeScript/pull/10554/files

84 fix: dont add to parent from `_setupAsRootView` by farfromrefug · Pull Request #10554 · NativeScript/NativeScript · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dont add to parent from _setupAsRootView #10554

Merged
merged 2 commits into from
Jun 28, 2024
Merged
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
13 changes: 11 additions & 2 deletions packages/core/ui/core/view-base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,17 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
// }
}

/**
* if _setupAsRootView is called it means it is not supposed to be
* added to a parent. However parent can be set before for the purpose
* of CSS variables/classes. That variable ensures that _addViewToNativeVisualTree
* is not called in _setupAsRootView
*/
mIsRootView = false;
_setupAsRootView(context: any): void {
this.mIsRootView = true;
this._setupUI(context);
this.mIsRootView = false;
}

/**
Expand All @@ -1025,7 +1034,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
// this check is unnecessary as this function should never be called when this._context === context as it means the view was somehow detached,
// which is only possible by setting reusable = true. Adding it either way for feature flag safety
if (this.reusable) {
if (this.parent && !this._isAddedToNativeVisualTree) {
if (!this.mIsRootView && this.parent && !this._isAddedToNativeVisualTree) {
const nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex);
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
}
Expand Down Expand Up @@ -1100,7 +1109,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition

this.setNativeView(nativeView);

if (this.parent) {
if (!this.mIsRootView && this.parent) {
const nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex);
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
}
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/NativeScript/pull/10554/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy