Skip to content

Commit 4551da0

Browse files
authored
fix(ios): resilience to nativeView access under edge cases (#10276)
1 parent c63a50a commit 4551da0

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

packages/core/ui/core/view/index.ios.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -898,13 +898,15 @@ export class View extends ViewCommon implements ViewDefinition {
898898
CATransaction.begin();
899899
}
900900

901-
if (value instanceof UIColor) {
902-
this.nativeViewProtected.backgroundColor = value;
903-
} else {
904-
iosBackground.createBackgroundUIColor(this, (color: UIColor) => {
905-
this.nativeViewProtected.backgroundColor = color;
906-
});
907-
this._setNativeClipToBounds();
901+
if (this.nativeViewProtected) {
902+
if (value instanceof UIColor) {
903+
this.nativeViewProtected.backgroundColor = value;
904+
} else {
905+
iosBackground.createBackgroundUIColor(this, (color: UIColor) => {
906+
this.nativeViewProtected.backgroundColor = color;
907+
});
908+
this._setNativeClipToBounds();
909+
}
908910
}
909911

910912
if (!updateSuspended) {
@@ -915,8 +917,10 @@ export class View extends ViewCommon implements ViewDefinition {
915917
}
916918

917919
_setNativeClipToBounds() {
918-
const backgroundInternal = this.style.backgroundInternal;
919-
this.nativeViewProtected.clipsToBounds = (this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius()) && !backgroundInternal.hasBoxShadow();
920+
if (this.nativeViewProtected) {
921+
const backgroundInternal = this.style.backgroundInternal;
922+
this.nativeViewProtected.clipsToBounds = (this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius()) && !backgroundInternal.hasBoxShadow();
923+
}
920924
}
921925

922926
private _setupPopoverControllerDelegate(controller: UIViewController, parent: View) {

packages/core/ui/layouts/layout-base.ios.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export class LayoutBase extends LayoutBaseCommon {
2323

2424
_setNativeClipToBounds() {
2525
if (this.clipToBounds) {
26-
this.nativeViewProtected.clipsToBounds = true;
26+
if (this.nativeViewProtected) {
27+
this.nativeViewProtected.clipsToBounds = true;
28+
}
2729
} else {
2830
super._setNativeClipToBounds();
2931
}

packages/core/ui/list-view/index.ios.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ export class ListView extends ListViewBase {
275275

276276
_setNativeClipToBounds() {
277277
// Always set clipsToBounds for list-view
278-
this.ios.clipsToBounds = true;
278+
if (this.ios) {
279+
this.ios.clipsToBounds = true;
280+
}
279281
}
280282

281283
@profile

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy