[ios, macos] Fix keypath expressions, json object is parsed incorrectly for nested keypaths. (#11959)

* [ios, macos] Fix keypath expressions, a json object is parsed incorrectly for nested keypaths.

* [ios, macos] Update changelogs.
This commit is contained in:
Fabian Guerra Soto
2018-05-23 13:21:31 -04:00
committed by GitHub
parent 464fefab18
commit 3ea1a7062f
4 changed files with 16 additions and 1 deletions

View File

@@ -1070,7 +1070,8 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
case NSKeyPathExpressionType: {
NSArray *expressionObject;
for (NSString *pathComponent in self.keyPath.pathComponents.reverseObjectEnumerator) {
NSArray *keyPath = [self.keyPath componentsSeparatedByString:@"."];
for (NSString *pathComponent in keyPath) {
if (expressionObject) {
expressionObject = @[@"get", pathComponent, expressionObject];
} else {

View File

@@ -306,6 +306,18 @@ using namespace std::string_literals;
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
NSExpression *expression = [NSExpression expressionForKeyPath:@"lineStyle.color"];
NSArray *jsonExpression = @[@"get", @"color", @[@"get", @"lineStyle"]];
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
NSExpression *expression = [NSExpression expressionForKeyPath:@"map.box.gl"];
NSArray *jsonExpression = @[@"get", @"gl", @[@"get", @"box", @[@"get", @"map"]]];
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
}
- (void)testStatisticalExpressionObject {

View File

@@ -17,6 +17,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Unknown tokens in URLs are now preserved, rather than replaced with an empty string. ([#11787](https://github.com/mapbox/mapbox-gl-native/issues/11787))
* Adjusted when and how the camera transition update and finish callbacks are called, fixing recursion bugs. ([#11614](https://github.com/mapbox/mapbox-gl-native/pull/11614))
* Improved application launch performance.
* Fixed an issue preventing nested key path expressions get parsed accordingly to the spec. ([#11959](https://github.com/mapbox/mapbox-gl-native/pull/11959))
## 4.0.1 - May 14, 2018

View File

@@ -14,6 +14,7 @@
* Unknown tokens in URLs are now preserved, rather than replaced with an empty string. ([#11787](https://github.com/mapbox/mapbox-gl-native/issues/11787))
* Adjusted when and how the camera transition update and finish callbacks are called, fixing recursion bugs. ([#11614](https://github.com/mapbox/mapbox-gl-native/pull/11614))
* Fixed an issue preventing nested key path expressions get parsed accordingly to the spec. ([#11959](https://github.com/mapbox/mapbox-gl-native/pull/11959))
## 0.7.1