Match-id-84feb6c23a62575d05498156164c47754deaeeb0
This commit is contained in:
commit
3f93ee4c1b
|
@ -7,7 +7,6 @@ import {
|
||||||
EVENT_TYPE_BUBBLE,
|
EVENT_TYPE_BUBBLE,
|
||||||
EVENT_TYPE_CAPTURE,
|
EVENT_TYPE_CAPTURE,
|
||||||
} from './const';
|
} from './const';
|
||||||
import { getListeners as getBeforeInputListeners } from './simulatedEvtHandler/BeforeInputEventHandler';
|
|
||||||
import { getListeners as getChangeListeners } from './simulatedEvtHandler/ChangeEventHandler';
|
import { getListeners as getChangeListeners } from './simulatedEvtHandler/ChangeEventHandler';
|
||||||
import { getListeners as getSelectionListeners } from './simulatedEvtHandler/SelectionEventHandler';
|
import { getListeners as getSelectionListeners } from './simulatedEvtHandler/SelectionEventHandler';
|
||||||
import {
|
import {
|
||||||
|
@ -105,15 +104,6 @@ function getProcessListeners(
|
||||||
target,
|
target,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (horizonEventToNativeMap.get('onBeforeInput').includes(nativeEvtName)) {
|
|
||||||
listenerList = listenerList.concat(getBeforeInputListeners(
|
|
||||||
nativeEvtName,
|
|
||||||
nativeEvent,
|
|
||||||
vNode,
|
|
||||||
target,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return listenerList;
|
return listenerList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ export const horizonEventToNativeMap = new Map([
|
||||||
['onCompositionEnd', ['compositionend']],
|
['onCompositionEnd', ['compositionend']],
|
||||||
['onCompositionStart', ['compositionstart']],
|
['onCompositionStart', ['compositionstart']],
|
||||||
['onCompositionUpdate', ['compositionupdate']],
|
['onCompositionUpdate', ['compositionupdate']],
|
||||||
['onBeforeInput', ['compositionend', 'keypress', 'textInput']],
|
|
||||||
['onChange', ['change', 'click', 'focusout', 'input']],
|
['onChange', ['change', 'click', 'focusout', 'input']],
|
||||||
['onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin',
|
['onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin',
|
||||||
'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']],
|
'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']],
|
||||||
|
@ -71,7 +70,6 @@ export const CommonEventToHorizonMap = {
|
||||||
compositionupdate: 'compositionUpdate',
|
compositionupdate: 'compositionUpdate',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CHAR_CODE_ENTER = 13;
|
|
||||||
export const CHAR_CODE_SPACE = 32;
|
export const CHAR_CODE_SPACE = 32;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
Loading…
Reference in New Issue