refactor(core): remove unused preventDefault on listener (#55879)

`wrapListener` was only invoked with `wrapWithPreventDefault` set to `false`.

PR Close #55879
This commit is contained in:
Matthieu Riegler
2024-05-19 23:01:04 +02:00
committed by Dylan Hunn
parent 76633847a2
commit a0690fe19f
@@ -216,7 +216,7 @@ export function listenerInternal(
(<any>existingListener).__ngLastListenerFn__ = listenerFn;
processOutputs = false;
} else {
listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
listenerFn = wrapListener(tNode, lView, context, listenerFn);
const cleanupFn = renderer.listen(target as RElement, eventName, listenerFn);
ngDevMode && ngDevMode.rendererAddEventListener++;
@@ -226,7 +226,7 @@ export function listenerInternal(
} else {
// Even if there is no native listener to add, we still need to wrap the listener so that OnPush
// ancestors are marked dirty when an event occurs.
listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
listenerFn = wrapListener(tNode, lView, context, listenerFn);
}
// subscribe to directive outputs
@@ -292,7 +292,6 @@ function wrapListener(
lView: LView<{} | null>,
context: {} | null,
listenerFn: (e?: any) => any,
wrapWithPreventDefault: boolean,
): EventListener {
// Note: we are performing most of the work in the listener function itself
// to optimize listener registration.
@@ -319,10 +318,6 @@ function wrapListener(
nextListenerFn = (<any>nextListenerFn).__ngNextListenerFn__;
}
if (wrapWithPreventDefault && result === false) {
e.preventDefault();
}
return result;
};
}