Skip to content

Commit

Permalink
Fix format expression validation by recursively unbundling expression…
Browse files Browse the repository at this point in the history
… objects
  • Loading branch information
ahk committed Jun 11, 2019
1 parent 5eabe50 commit 93a4216
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/style-spec/util/unbundle_jsonlint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
function isPrimitive(value) {
return value instanceof Number || value instanceof String || value instanceof Boolean;
}

// Turn jsonlint-lines-primitives objects into primitive objects
export function unbundle(value) {
if (value instanceof Number || value instanceof String || value instanceof Boolean) {
if (isPrimitive(value)) {
return value.valueOf();
} else {
return value;
Expand All @@ -11,7 +14,14 @@ export function unbundle(value) {
export function deepUnbundle(value) {
if (Array.isArray(value)) {
return value.map(deepUnbundle);
} else if (value instanceof Object && !isPrimitive(value)) {
const unbundledValue = {};
for (let key in value) {
unbundledValue[key] = deepUnbundle(value[key]);
}
return unbundledValue;
}

return unbundle(value);
}

0 comments on commit 93a4216

Please sign in to comment.