Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 79ecf1e

Browse filesBrowse files
authored
Fix wrong AST for asycn function in v-on (#227)
* Fix wrong AST for asycn function in v-on * chore: add comment * chore: fix comment
1 parent ae61e8d commit 79ecf1e
Copy full SHA for 79ecf1e

File tree

9 files changed

+2011
-2
lines changed
Filter options

9 files changed

+2011
-2
lines changed

‎src/script/index.ts

Copy file name to clipboardExpand all lines: src/script/index.ts
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,15 @@ const PARENS = /^(\s*\()([\s\S]*?)(\)\s*)$/u
7575
const DUMMY_PARENT: any = {}
7676

7777
// Like Vue, it judges whether it is a function expression or not.
78-
// https://github.com/vuejs/vue/blob/0948d999f2fddf9f90991956493f976273c5da1f/src/compiler/codegen/events.js#L3
79-
const IS_FUNCTION_EXPRESSION = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/u
78+
// https://github.com/vuejs/core/blob/fef2acb2049fce3407dff17fe8af1836b97dfd73/packages/compiler-core/src/transforms/vOn.ts#L19
79+
const IS_FUNCTION_EXPRESSION =
80+
/^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/u
81+
// ^^^^^^^ omit paren argument ^^^^^^^^ function keyword
82+
// ^^^^^ <--- async keyword (optional) ---> ^^^^^
83+
// ^^------^^ arguments with parens ^^^^^^ named function (optional)
84+
// ^^^^^^^^^ return types (optional)
85+
// ^^ arrow ^^ opening paren
86+
8087
const IS_SIMPLE_PATH =
8188
/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?'\]|\["[^"]*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/u
8289

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.