Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit79ecf1e

Browse 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 parentae61e8d commit79ecf1e

File tree

9 files changed

+2011
-2
lines changed

9 files changed

+2011
-2
lines changed

‎src/script/index.ts

Lines 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
constDUMMY_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-
constIS_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+
constIS_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
constIS_SIMPLE_PATH=
8188
/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?'\]|\["[^"]*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/u
8289

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp