support shorthand method name in object literal (#4264)
This commit is contained in:
24
lib/parse.js
24
lib/parse.js
@@ -1342,6 +1342,20 @@ function parse($TEXT, options) {
|
||||
var start = S.token;
|
||||
var type = start.type;
|
||||
var name = as_property_name();
|
||||
if (is("punc", "(")) {
|
||||
var func_start = S.token;
|
||||
var func = function_(AST_Function);
|
||||
func.start = func_start;
|
||||
func.end = prev();
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start: start,
|
||||
quote: start.quote,
|
||||
key: "" + name,
|
||||
value: func,
|
||||
end: prev(),
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (!is("punc", ":") && type == "name") switch (name) {
|
||||
case "get":
|
||||
a.push(new AST_ObjectGetter({
|
||||
@@ -1379,11 +1393,11 @@ function parse($TEXT, options) {
|
||||
}
|
||||
expect(":");
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start : start,
|
||||
quote : start.quote,
|
||||
key : "" + name,
|
||||
value : expression(false),
|
||||
end : prev()
|
||||
start: start,
|
||||
quote: start.quote,
|
||||
key: "" + name,
|
||||
value: expression(false),
|
||||
end: prev(),
|
||||
}));
|
||||
}
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user