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
[TIMOB-26179] Check for property existence using hasProperty #10150
Conversation
Tests:
Generated by 🚫 dangerJS |
LGTM. But please add a unit-test for it since it should be somehow testable from our proxy implementation. Also, do you have a practical use case for this that is worth mentioning? |
NSString *name = (NSString *)TiStringCopyCFString(kCFAllocatorDefault, propertyName); | ||
[name autorelease]; | ||
id result = [o valueForKey:name]; | ||
if (result != nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collapse the last few lines down to:
return result != nil;
I think it'd be pretty easy to add a quick unit test that generated a proxy and then just tested for a non-existent and existing own property. I believe iOS always returned true before? var label = Ti.UI.createLabel();
should(label.hasOwnProperty('madeup')).eql(false);
should(label.hasOwnProperty('text')).eql(true);
label.madeup = 123;
should(label.hasOwnProperty('madeup')).eql(true); |
…tor for Ti proxies
JIRA: https://jira.appcelerator.org/browse/TIMOB-26179
Optional Description:
Implements the
hasProperty
callback to properly check for property existence in our proxy objects. Without this callbackgetProperty
is which results in property checks always returningtrue
.@hansemannn Not sure if this implies a breaking change or can just be considered as a re-definition of previously undefined behavior.