From 1ed7e608cc5e3246c874e9df4484b969914a1ab5 Mon Sep 17 00:00:00 2001 From: * <8> Date: Tue, 22 Feb 2022 10:13:35 +0800 Subject: [PATCH] Match-id-6208d162f4af32a98c0b3a08ba5648aefc074f3b --- libs/horizon/src/event/HorizonEventMain.ts | 6 ++++-- libs/horizon/src/event/utils.ts | 9 --------- 2 files changed, 4 insertions(+), 11 deletions(-) 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) {