diff --git a/libs/horizon/src/event/HorizonEventMain.ts b/libs/horizon/src/event/HorizonEventMain.ts index c550fdbe..08e9f5d0 100644 --- a/libs/horizon/src/event/HorizonEventMain.ts +++ b/libs/horizon/src/event/HorizonEventMain.ts @@ -10,7 +10,7 @@ import { import { getListeners as getChangeListeners } from './simulatedEvtHandler/ChangeEventHandler'; import { getListeners as getSelectionListeners } from './simulatedEvtHandler/SelectionEventHandler'; import { - addOnPrefix, setPropertyWritable, + setPropertyWritable, } from './utils'; import { decorateNativeEvent } from './customEvents/EventFactory'; import { getListenersFromTree } from './ListenerGetter'; @@ -27,7 +27,9 @@ function getCommonListeners( target: null | EventTarget, isCapture: boolean, ): ListenerUnitList { - const horizonEvtName = addOnPrefix(CommonEventToHorizonMap[nativeEvtName]); + const name = CommonEventToHorizonMap[nativeEvtName]; + const horizonEvtName = !name ? '' : `on${name[0].toUpperCase()}${name.slice(1)}`; // 例:dragEnd -> onDragEnd + if (!horizonEvtName) { return []; } diff --git a/libs/horizon/src/event/utils.ts b/libs/horizon/src/event/utils.ts index d4b6f143..09d1b240 100644 --- a/libs/horizon/src/event/utils.ts +++ b/libs/horizon/src/event/utils.ts @@ -6,15 +6,6 @@ export function isInputElement(dom?: HTMLElement): boolean { return false; } - -// 例:dragEnd -> onDragEnd -export function addOnPrefix(name) { - if (!name) { - return ''; - } - return 'on' + name[0].toUpperCase() + name.slice(1); -} - export function setPropertyWritable(obj, propName) { const desc = Object.getOwnPropertyDescriptor(obj, propName); if (!desc || !desc.writable) {