Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Fix keypath expressions, json object is parsed incorrect…
Browse files Browse the repository at this point in the history
…ly for nested keypaths. (#11959)

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

* [ios, macos] Update changelogs.
  • Loading branch information
fabian-guerra committed May 23, 2018
1 parent 464fefa commit 3ea1a70
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion platform/darwin/src/NSExpression+MGLAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,8 @@ - (id)mgl_jsonExpressionObject {

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 {
Expand Down
12 changes: 12 additions & 0 deletions platform/darwin/test/MGLExpressionTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ - (void)testKeyPathExpressionObject {
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 {
Expand Down
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3ea1a70

Please sign in to comment.