support optional chaining operator (#4899)

This commit is contained in:
Alex Lam S.L
2021-05-03 03:08:29 +01:00
committed by GitHub
parent 203f4b7ad9
commit f0de9a8b5d
12 changed files with 353 additions and 71 deletions

View File

@@ -274,6 +274,7 @@
return new (M.computed ? AST_Sub : AST_Dot)({
start: my_start_token(M),
end: my_end_token(M),
optional: M.optional,
expression: from_moz(M.object),
property: M.computed ? from_moz(M.property) : M.property.name,
});
@@ -554,6 +555,9 @@
node.end.parens.push(my_end_token(M));
return node;
},
ChainExpression: function(M) {
return from_moz(M.expression);
},
};
MOZ_TO_ME.UpdateExpression =
@@ -593,7 +597,7 @@
map("AssignmentPattern", AST_DefaultValue, "left>name, right>value");
map("ConditionalExpression", AST_Conditional, "test>condition, consequent>consequent, alternate>alternative");
map("NewExpression", AST_New, "callee>expression, arguments@args, pure=pure");
map("CallExpression", AST_Call, "callee>expression, arguments@args, pure=pure");
map("CallExpression", AST_Call, "callee>expression, arguments@args, optional=optional, pure=pure");
map("SequenceExpression", AST_Sequence, "expressions@expressions");
map("SpreadElement", AST_Spread, "argument>expression");
map("ObjectExpression", AST_Object, "properties@properties");
@@ -868,6 +872,7 @@
type: "MemberExpression",
object: to_moz(M.expression),
computed: computed,
optional: M.optional,
property: computed ? to_moz(M.property) : {
type: "Identifier",
name: M.property,