Skip to content

Commit 15f75e9

Browse files
committed
fix: fix parsing chained modifiers
1 parent d4c9063 commit 15f75e9

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/walk.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,10 @@ const processDirective = (
121121
let modifiers: Record<string, true> | undefined
122122

123123
// modifiers
124-
let modMatch: RegExpExecArray | null = null
125-
while ((modMatch = modifierRE.exec(raw))) {
126-
;(modifiers || (modifiers = {}))[modMatch[1]] = true
127-
raw = raw.slice(0, modMatch.index)
128-
}
124+
raw = raw.replace(modifierRE, (_, m) => {
125+
;(modifiers || (modifiers = {}))[m] = true
126+
return ''
127+
})
129128

130129
if (raw[0] === ':') {
131130
dir = bind

tests/on.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
placeholder="type x to test key modifier"
1212
/>
1313
<form>
14-
<button type="submit" @click.prevent>submit (prevented)</button>
14+
<button type="submit" @click.prevent.stop>submit (prevented)</button>
1515
</form>
1616
<button @click.right="alert('clicked')">right click</button>
1717
<button @click.middle="alert('clicked')">middle click</button>

0 commit comments

Comments
 (0)