fix(ios): resilience to nativeView access under edge cases (#10276)

This commit is contained in:
Nathan Walker
2023-04-24 13:45:31 -07:00
committed by GitHub
parent c63a50a196
commit 4551da075b
3 changed files with 19 additions and 11 deletions

View File

@ -898,13 +898,15 @@ export class View extends ViewCommon implements ViewDefinition {
CATransaction.begin(); CATransaction.begin();
} }
if (value instanceof UIColor) { if (this.nativeViewProtected) {
this.nativeViewProtected.backgroundColor = value; if (value instanceof UIColor) {
} else { this.nativeViewProtected.backgroundColor = value;
iosBackground.createBackgroundUIColor(this, (color: UIColor) => { } else {
this.nativeViewProtected.backgroundColor = color; iosBackground.createBackgroundUIColor(this, (color: UIColor) => {
}); this.nativeViewProtected.backgroundColor = color;
this._setNativeClipToBounds(); });
this._setNativeClipToBounds();
}
} }
if (!updateSuspended) { if (!updateSuspended) {
@ -915,8 +917,10 @@ export class View extends ViewCommon implements ViewDefinition {
} }
_setNativeClipToBounds() { _setNativeClipToBounds() {
const backgroundInternal = this.style.backgroundInternal; if (this.nativeViewProtected) {
this.nativeViewProtected.clipsToBounds = (this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius()) && !backgroundInternal.hasBoxShadow(); const backgroundInternal = this.style.backgroundInternal;
this.nativeViewProtected.clipsToBounds = (this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius()) && !backgroundInternal.hasBoxShadow();
}
} }
private _setupPopoverControllerDelegate(controller: UIViewController, parent: View) { private _setupPopoverControllerDelegate(controller: UIViewController, parent: View) {

View File

@ -23,7 +23,9 @@ export class LayoutBase extends LayoutBaseCommon {
_setNativeClipToBounds() { _setNativeClipToBounds() {
if (this.clipToBounds) { if (this.clipToBounds) {
this.nativeViewProtected.clipsToBounds = true; if (this.nativeViewProtected) {
this.nativeViewProtected.clipsToBounds = true;
}
} else { } else {
super._setNativeClipToBounds(); super._setNativeClipToBounds();
} }

View File

@ -275,7 +275,9 @@ export class ListView extends ListViewBase {
_setNativeClipToBounds() { _setNativeClipToBounds() {
// Always set clipsToBounds for list-view // Always set clipsToBounds for list-view
this.ios.clipsToBounds = true; if (this.ios) {
this.ios.clipsToBounds = true;
}
} }
@profile @profile