diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-12-17 10:23:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 18:23:41 +0800 |
commit | a96f087ac33b6d18d5ffa3cacd39dd693defb7cf (patch) | |
tree | d670eab7971cb7bf27e029319db0357ff38e51d5 /lib/utils.js | |
parent | 75e9fd84174eaa8bf97975ad254fe06958564547 (diff) | |
download | tracifyjs-a96f087ac33b6d18d5ffa3cacd39dd693defb7cf.tar.gz tracifyjs-a96f087ac33b6d18d5ffa3cacd39dd693defb7cf.zip |
support arrow function (#4385)
Diffstat (limited to 'lib/utils.js')
-rw-r--r-- | lib/utils.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/utils.js b/lib/utils.js index 2a0df8c5..286266a2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -238,13 +238,15 @@ function HOP(obj, prop) { // return true if the node at the top of the stack (that means the // innermost node in the current output) is lexically the first in // a statement. -function first_in_statement(stack) { +function first_in_statement(stack, arrow) { var node = stack.parent(-1); for (var i = 0, p; p = stack.parent(i++); node = p) { - if (p.TYPE == "Call") { - if (p.expression === node) continue; + if (p instanceof AST_Arrow) { + return arrow && p.value === node; } else if (p instanceof AST_Binary) { if (p.left === node) continue; + } else if (p.TYPE == "Call") { + if (p.expression === node) continue; } else if (p instanceof AST_Conditional) { if (p.condition === node) continue; } else if (p instanceof AST_PropAccess) { |