2019-11-08 14:52:24 +00:00
|
|
|
import { isArray } from '@vue/shared'
|
2018-10-28 21:43:27 +00:00
|
|
|
import { TestElement } from './nodeOps'
|
|
|
|
|
|
|
|
export function triggerEvent(
|
|
|
|
el: TestElement,
|
|
|
|
event: string,
|
|
|
|
payload: any[] = []
|
|
|
|
) {
|
|
|
|
const { eventListeners } = el
|
|
|
|
if (eventListeners) {
|
|
|
|
const listener = eventListeners[event]
|
|
|
|
if (listener) {
|
2019-11-08 14:52:24 +00:00
|
|
|
if (isArray(listener)) {
|
2018-10-28 21:43:27 +00:00
|
|
|
for (let i = 0; i < listener.length; i++) {
|
|
|
|
listener[i](...payload)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
listener(...payload)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|