Skip to content

Commit 5556fcc

Browse files
tmcwadrianheine
authored andcommitted
Permit quoted names for object destructuring in JavaScript syntax
1 parent e4ca909 commit 5556fcc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

mode/javascript/javascript.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
655655
if (type == "variable") cx.marked = "property";
656656
if (type == "spread") return cont(pattern);
657657
if (type == "}") return pass();
658+
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
658659
return cont(expect(":"), pattern, maybeAssign);
659660
}
660661
function eltpattern() {

mode/javascript/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@
226226
" [keyword return] [variable-2 x];",
227227
"}");
228228

229+
MT(
230+
"param_destructuring",
231+
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
232+
" [keyword return] [variable-2 x];",
233+
"}");
234+
229235
MT("new_target",
230236
"[keyword function] [def F]([def target]) {",
231237
" [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",

0 commit comments

Comments
 (0)