File tree 1 file changed +5
-7
lines changed
packages/runtime-dom/src/modules
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export function patchEvent(
17
17
}
18
18
19
19
const eventCounts : Record < string , number > = { }
20
- const attachedGlobalHandlers : Record < string , Function > = { }
20
+ const attachedGlobalHandlers : Record < string , Function | null > = { }
21
21
22
22
export function handleDelegatedEvent (
23
23
el : any ,
@@ -38,18 +38,16 @@ export function handleDelegatedEvent(
38
38
}
39
39
store [ name ] = value
40
40
} else if ( store && store [ name ] ) {
41
- eventCounts [ name ] --
42
- store [ name ] = null
43
- if ( count === 1 ) {
41
+ if ( -- eventCounts [ name ] === 0 ) {
44
42
removeGlobalHandler ( name )
45
43
}
44
+ store [ name ] = null
46
45
}
47
46
}
48
47
49
48
function attachGlobalHandler ( name : string ) {
50
49
const handler = ( attachedGlobalHandlers [ name ] = ( e : Event ) => {
51
- const { type } = e
52
- const isClick = type === 'click' || type === 'dblclick'
50
+ const isClick = e . type === 'click' || e . type === 'dblclick'
53
51
if ( isClick && ( e as MouseEvent ) . button !== 0 ) {
54
52
e . stopPropagation ( )
55
53
return false
@@ -114,7 +112,7 @@ function invokeEvents(e: Event, value: EventValue) {
114
112
115
113
function removeGlobalHandler ( name : string ) {
116
114
document . removeEventListener ( name , attachedGlobalHandlers [ name ] as any )
117
- eventCounts [ name ] = 0
115
+ attachedGlobalHandlers [ name ] = null
118
116
}
119
117
120
118
function handleNormalEvent ( el : Element , name : string , prev : any , next : any ) {
You can’t perform that action at this time.
0 commit comments