mirror of
https://github.com/hanzoai/Detox.git
synced 2026-09-24 16:55:12 +00:00
Fixed crash in Google Maps SDK, caused by exposing a text property on every object
This commit is contained in:
+5
-1
@@ -10,4 +10,8 @@ detox/test/ios/* @LeoNatan
|
||||
*.m @LeoNatan
|
||||
*.mm @LeoNatan
|
||||
*.cpp @LeoNatan
|
||||
*.sh @rotemmiz
|
||||
*.swift @LeoNatan
|
||||
*.pch @LeoNatan
|
||||
*.plist @LeoNatan
|
||||
|
||||
*.sh @rotemmiz
|
||||
@@ -216,7 +216,7 @@ class Element : NSObject {
|
||||
|
||||
@objc
|
||||
var text: String? {
|
||||
return view.value(forKey: "text") as? String
|
||||
return view.value(forKey: "dtx_text") as? String
|
||||
}
|
||||
|
||||
@objc
|
||||
|
||||
@@ -193,7 +193,7 @@ BOOL __DTXPointEqualToPoint(CGPoint a, CGPoint b)
|
||||
|
||||
- (NSString *)dtx_text
|
||||
{
|
||||
id rv = [self text];
|
||||
id rv = [self _dtx_text];
|
||||
if(rv == nil || [rv isKindOfClass:NSString.class])
|
||||
{
|
||||
return rv;
|
||||
|
||||
@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSObject (DontCrash)
|
||||
|
||||
- (id)text;
|
||||
- (id)_dtx_text;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -9,10 +9,19 @@
|
||||
|
||||
@implementation NSObject (DontCrash)
|
||||
|
||||
- (id)text
|
||||
- (id)_dtx_text
|
||||
{
|
||||
Class cls = NSClassFromString(@"RCTTextView");
|
||||
if(cls != nil && [self isKindOfClass:cls])
|
||||
if([self respondsToSelector:@selector(text)])
|
||||
{
|
||||
return [(UITextView*)self text];
|
||||
}
|
||||
|
||||
static Class RCTTextView;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
RCTTextView = NSClassFromString(@"RCTTextView");
|
||||
});
|
||||
if(RCTTextView != nil && [self isKindOfClass:RCTTextView])
|
||||
{
|
||||
return [(NSTextStorage*)[self valueForKey:@"textStorage"] string];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user