-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make style properties null-resettable; fix property function roundtripping #6168
Conversation
Every enumeration-typed property test is failing on the iOS build bot:
However, I’m unable to reproduce this failure locally. |
If the property is unset, return the default value. Fixes #6126.
5bd4ad8
to
34901b0
Compare
The test failures turned out to be legitimate. The tests caught yet another roundtripping issue. |
case 'color': | ||
let color = parseColor(value); | ||
if (!color) { | ||
throw new Error(`unrecognized color format in default value of ${property.name}`); | ||
} | ||
if (color.r === 0 && color.g === 0 && color.b === 0 && color.a === 0) { | ||
return '`clearColor`'; | ||
return '`NSColor.clearColor` or `UIColor.clearColor`'; |
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.
Nit: it seems to me that the iOS variant should come before macOS’s.
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.
Rest assured, I was being completely objective and dispassionate by alphabetizing the items in this list. 😉
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.
The entire declaration and its comment are now duplicated once per platform using conditional compilation macros. Each comment says only NSColor or UIColor as appropriate. Out of respect for iOS’s primacy, the UIKit version comes first.
Other than my iOS partisanship, this LGTM. 👍 |
The documentation for runtime style API properties now spells out the value of the default type, to help developers infer the type of the property itself.
Also support unsetting enumeration-typed properties.
Duplicate each color-typed property once per platform using conditional compilation macros. Let’s just hope we never have to throw CGColor into the mix.
34901b0
to
f4be826
Compare
This PR includes several interwoven changes, all related to the runtime styling API:
null_resettable
in Objective-C and therefore implicitly unwrapped optionals in Swift. Instead of returningnil
when unset, these properties now return the intrinsic default value. (Fixes MGLStyleLayer properties should be null_resettable or nonnull #6126.)nil
. (Fixes Getters for enumeration-typed style properties return nil instead of functions #6161.)/cc @frederoni