Match-id-ac97403ba9a015c0c8a8162ce9cbdb60ac0802a1
This commit is contained in:
commit
e578f6a77d
|
@ -1,24 +0,0 @@
|
|||
// 处理事件的错误
|
||||
let hasError = false;
|
||||
let caughtError = null;
|
||||
|
||||
// 执行事件监听器,并且捕捉第一个错误,事件执行完成后抛出第一个错误
|
||||
export function runListenerAndCatchFirstError(listener, event) {
|
||||
try {
|
||||
listener(event);
|
||||
} catch (error) {
|
||||
if (!hasError) {
|
||||
hasError = true;
|
||||
caughtError = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function throwCaughtEventError() {
|
||||
if (hasError) {
|
||||
const err = caughtError;
|
||||
caughtError = null;
|
||||
hasError = false;
|
||||
throw err;
|
||||
}
|
||||
}
|
|
@ -7,10 +7,6 @@ import {
|
|||
EVENT_TYPE_BUBBLE,
|
||||
EVENT_TYPE_CAPTURE,
|
||||
} from './const';
|
||||
import {
|
||||
throwCaughtEventError,
|
||||
runListenerAndCatchFirstError,
|
||||
} from './EventError';
|
||||
import { getListeners as getBeforeInputListeners } from './simulatedEvtHandler/BeforeInputEventHandler';
|
||||
import { getListeners as getCompositionListeners } from './simulatedEvtHandler/CompositionEventHandler';
|
||||
import { getListeners as getChangeListeners } from './simulatedEvtHandler/ChangeEventHandler';
|
||||
|
@ -75,12 +71,9 @@ function processListeners(listenerList: ListenerUnitList): void {
|
|||
return;
|
||||
}
|
||||
event.currentTarget = currentTarget;
|
||||
runListenerAndCatchFirstError(listener, event);
|
||||
listener(event);
|
||||
event.currentTarget = null;
|
||||
});
|
||||
|
||||
// 执行所有事件后,重新throw遇到的第一个错误
|
||||
throwCaughtEventError();
|
||||
}
|
||||
|
||||
function getProcessListenersFacade(
|
||||
|
|
Loading…
Reference in New Issue