Skip to content

Commit eaf3a7e

Browse files
committed
[javascript mode] Allow default values on array pattern elements
Closes #5556
1 parent b756744 commit eaf3a7e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mode/javascript/javascript.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
644644
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
645645
if (type == "variable") { register(value); return cont(); }
646646
if (type == "spread") return cont(pattern);
647-
if (type == "[") return contCommasep(pattern, "]");
647+
if (type == "[") return contCommasep(eltpattern, "]");
648648
if (type == "{") return contCommasep(proppattern, "}");
649649
}
650650
function proppattern(type, value) {
@@ -657,6 +657,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
657657
if (type == "}") return pass();
658658
return cont(expect(":"), pattern, maybeAssign);
659659
}
660+
function eltpattern() {
661+
return cont(pattern, maybeAssign)
662+
}
660663
function maybeAssign(_type, value) {
661664
if (value == "=") return cont(expressionNoComma);
662665
}

0 commit comments

Comments
 (0)