aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-03-02 04:08:08 +0000
committerGitHub <noreply@github.com>2021-03-02 12:08:08 +0800
commit62887f2c66491846ab5c08e348373bdad07ea9a2 (patch)
treec2f58f66262c85e2195eee6a167f9195f9a83709 /lib
parent68b2dadc58d649f3a917b602a66804ad50aae2ae (diff)
downloadtracifyjs-62887f2c66491846ab5c08e348373bdad07ea9a2.tar.gz
tracifyjs-62887f2c66491846ab5c08e348373bdad07ea9a2.zip
fix corner case with `class` (#4713)
Diffstat (limited to 'lib')
-rw-r--r--lib/parse.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 2cb30409..0798062d 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -1053,6 +1053,16 @@ function parse($TEXT, options) {
return stat;
}
+ function has_modifier(name) {
+ if (!is("name", name)) return;
+ var token = peek();
+ if (!token) return;
+ if (is_token(token, "operator", "=")) return;
+ if (token.type == "punc" && /^[(;}]$/.test(token.value)) return;
+ if (has_newline_before(token)) return;
+ return next();
+ }
+
function class_(ctor) {
var was_async = S.in_async;
var was_gen = S.in_generator;
@@ -1078,16 +1088,8 @@ function parse($TEXT, options) {
continue;
}
var start = S.token;
- var fixed = is("name", "static");
- if (fixed) next();
- var async = is("name", "async") && peek();
- if (async) {
- if (async.type == "punc" && /^[(=;}]$/.test(async.value) || has_newline_before(async)) {
- async = false;
- } else {
- async = next();
- }
- }
+ var fixed = !!has_modifier("static");
+ var async = has_modifier("async");
if (is("operator", "*")) {
next();
var internal = is("name") && /^#/.test(S.token.value);