diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-11-08 05:17:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-08 13:17:53 +0800 |
commit | 1cbd07e7897bcbb879921c63b9794f7a278ca5a6 (patch) | |
tree | 0289e7cac60d186f9f2af9a98c1fd3b7808d7af7 /lib | |
parent | b82de04775a490f7a1ebf7a8911f7d1a24a5f0b6 (diff) | |
download | tracifyjs-1cbd07e7897bcbb879921c63b9794f7a278ca5a6.tar.gz tracifyjs-1cbd07e7897bcbb879921c63b9794f7a278ca5a6.zip |
support shorthand method name in object literal (#4264)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/parse.js b/lib/parse.js index 78311f89..84b14439 100644 --- a/lib/parse.js +++ b/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(); |