@@ -1011,8 +1011,17 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
1011
1011
// }
1012
1012
}
1013
1013
1014
+ /**
1015
+ * if _setupAsRootView is called it means it is not supposed to be
1016
+ * added to a parent. However parent can be set before for the purpose
1017
+ * of CSS variables/classes. That variable ensures that _addViewToNativeVisualTree
1018
+ * is not called in _setupAsRootView
1019
+ */
1020
+ mIsRootView = false ;
1014
1021
_setupAsRootView ( context : any ) : void {
1022
+ this . mIsRootView = true ;
1015
1023
this . _setupUI ( context ) ;
1024
+ this . mIsRootView = false ;
1016
1025
}
1017
1026
1018
1027
/**
@@ -1025,7 +1034,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
1025
1034
// this check is unnecessary as this function should never be called when this._context === context as it means the view was somehow detached,
1026
1035
// which is only possible by setting reusable = true. Adding it either way for feature flag safety
1027
1036
if ( this . reusable ) {
1028
- if ( this . parent && ! this . _isAddedToNativeVisualTree ) {
1037
+ if ( ! this . mIsRootView && this . parent && ! this . _isAddedToNativeVisualTree ) {
1029
1038
const nativeIndex = this . parent . _childIndexToNativeChildIndex ( atIndex ) ;
1030
1039
this . _isAddedToNativeVisualTree = this . parent . _addViewToNativeVisualTree ( this , nativeIndex ) ;
1031
1040
}
@@ -1100,7 +1109,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
1100
1109
1101
1110
this . setNativeView ( nativeView ) ;
1102
1111
1103
- if ( this . parent ) {
1112
+ if ( ! this . mIsRootView && this . parent ) {
1104
1113
const nativeIndex = this . parent . _childIndexToNativeChildIndex ( atIndex ) ;
1105
1114
this . _isAddedToNativeVisualTree = this . parent . _addViewToNativeVisualTree ( this , nativeIndex ) ;
1106
1115
}
0 commit comments