Match-id-84feb6c23a62575d05498156164c47754deaeeb0

This commit is contained in:
* 2022-02-21 14:33:43 +08:00 committed by *
commit 3f93ee4c1b
3 changed files with 0 additions and 58 deletions

View File

@ -7,7 +7,6 @@ import {
EVENT_TYPE_BUBBLE,
EVENT_TYPE_CAPTURE,
} from './const';
import { getListeners as getBeforeInputListeners } from './simulatedEvtHandler/BeforeInputEventHandler';
import { getListeners as getChangeListeners } from './simulatedEvtHandler/ChangeEventHandler';
import { getListeners as getSelectionListeners } from './simulatedEvtHandler/SelectionEventHandler';
import {
@ -105,15 +104,6 @@ function getProcessListeners(
target,
));
}
if (horizonEventToNativeMap.get('onBeforeInput').includes(nativeEvtName)) {
listenerList = listenerList.concat(getBeforeInputListeners(
nativeEvtName,
nativeEvent,
vNode,
target,
));
}
}
return listenerList;
}

View File

@ -27,7 +27,6 @@ export const horizonEventToNativeMap = new Map([
['onCompositionEnd', ['compositionend']],
['onCompositionStart', ['compositionstart']],
['onCompositionUpdate', ['compositionupdate']],
['onBeforeInput', ['compositionend', 'keypress', 'textInput']],
['onChange', ['change', 'click', 'focusout', 'input']],
['onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin',
'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']],
@ -71,7 +70,6 @@ export const CommonEventToHorizonMap = {
compositionupdate: 'compositionUpdate',
};
export const CHAR_CODE_ENTER = 13;
export const CHAR_CODE_SPACE = 32;

View File

@ -1,46 +0,0 @@
import type {VNode} from '../../renderer/Types';
import type {AnyNativeEvent} from '../Types';
import {getListenersFromTree} from '../ListenerGetter';
import {decorateNativeEvent} from '../customEvents/EventFactory';
import {CHAR_CODE_SPACE, EVENT_TYPE_ALL} from '../const';
import {ListenerUnitList} from '../Types';
const SPACE_CHAR = String.fromCharCode(CHAR_CODE_SPACE);
function getInputCharsByNative(
eventName: string,
nativeEvent: any,
): string | null {
if (eventName === 'compositionend') {
return (nativeEvent.detail && nativeEvent.detail.data) || null;
}
if (eventName === 'keypress') {
return nativeEvent.which === CHAR_CODE_SPACE ? SPACE_CHAR : null;
}
if (eventName === 'textInput') {
return nativeEvent.data === SPACE_CHAR ? null : nativeEvent.data;
}
return null;
}
// 自定义beforeInput的hook事件处理
export function getListeners(
nativeEvtName: string,
nativeEvent: AnyNativeEvent,
vNode: null | VNode,
target: null | EventTarget,
): ListenerUnitList {
const chars = getInputCharsByNative(nativeEvtName, nativeEvent);
// 无字符将要输入,无需处理
if (!chars) {
return [];
}
const event: AnyNativeEvent = decorateNativeEvent(
'onBeforeInput',
'beforeinput',
nativeEvent,
);
event.data = chars;
return getListenersFromTree(vNode, 'onBeforeInput', event, EVENT_TYPE_ALL);
}