refactor(platform-browser): drop unsupported event target error message in production (#60016)

Drops unsupported event target error message in production and replaces it with an existing error code.

PR Close #60016
This commit is contained in:
arturovt 2025-02-19 18:57:14 +02:00 committed by Andrew Kushnir
parent 5c70a048a9
commit a8ec7bebf2

View file

@ -419,13 +419,17 @@ class DefaultDomRenderer2 implements Renderer2 {
if (typeof target === 'string') {
target = getDOM().getGlobalEventTarget(this.doc, target);
if (!target) {
throw new Error(`Unsupported event target ${target} for event ${event}`);
throw new RuntimeError(
RuntimeErrorCode.UNSUPPORTED_EVENT_TARGET,
(typeof ngDevMode === 'undefined' || ngDevMode) &&
`Unsupported event target ${target} for event ${event}`,
);
}
}
let wrappedCallback = this.decoratePreventDefault(callback);
if (this.tracingService !== null && this.tracingService.wrapEventListener) {
if (this.tracingService?.wrapEventListener) {
wrappedCallback = this.tracingService.wrapEventListener(target, event, wrappedCallback);
}