iOS: Fixed some props conversion errors
Summary: * numbers in JS are doubles in native land, since there's no notion of int or int64 in JS - so simply convert numbers to int instead of assuming it's int * the parsing of Yoga props with `'...%'` string value has a bug: it should be copying the number instead of the `%` Reviewed By: shergin Differential Revision: D8370873 fbshipit-source-id: 44e9e3f0530c000c963e8e9ca66e8b0a48d80bcd
This commit is contained in:
parent
741c53c2fb
commit
119fd1efe7
|
@ -17,7 +17,11 @@ namespace facebook {
|
|||
namespace react {
|
||||
|
||||
inline void fromDynamic(const folly::dynamic &value, bool &result) { result = value.getBool(); }
|
||||
inline void fromDynamic(const folly::dynamic &value, int &result) { result = value.getInt(); }
|
||||
inline void fromDynamic(const folly::dynamic &value, int &result) {
|
||||
// All numbers from JS are treated as double, and JS cannot represent int64 in practice.
|
||||
// So this always converts the value to int64 instead.
|
||||
result = value.asInt();
|
||||
}
|
||||
inline void fromDynamic(const folly::dynamic &value, std::string &result) { result = value.getString(); }
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -201,7 +201,7 @@ inline void fromDynamic(const folly::dynamic &value, YGValue &result) {
|
|||
return;
|
||||
} else {
|
||||
if (stringValue.back() == '%') {
|
||||
result = { folly::to<float>(stringValue.substr(stringValue.length() - 1)), YGUnitPercent };
|
||||
result = { folly::to<float>(stringValue.substr(0, stringValue.length() - 1)), YGUnitPercent };
|
||||
return;
|
||||
} else {
|
||||
result = { folly::to<float>(stringValue), YGUnitPoint };
|
||||
|
|
Loading…
Reference in New Issue