Skip to content

Commit

Permalink
Improve walking of object patterns
Browse files Browse the repository at this point in the history
This isn't great, as it's hard-coding node names of child nodes,
but the way the walker handles different contexts (expression,
statement, pattern) doesn't allow for a proper solution here.

Issue #688
  • Loading branch information
marijnh committed Mar 21, 2018
1 parent 9b424d8 commit a12ccc6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/walk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@ base.ArrayPattern = (node, st, c) => {
}
base.ObjectPattern = (node, st, c) => {
for (let prop of node.properties) {
if (prop.computed) c(prop.key, st, "Expression")
c(prop.value, st, "Pattern")
if (prop.type === "Property") {
if (prop.computed) c(prop.key, st, "Expression")
c(prop.value, st, "Pattern")
} else if (prop.type === "RestElement") {
c(prop.argument, st, "Pattern")
}
}
}

Expand Down

0 comments on commit a12ccc6

Please sign in to comment.