Skip to content

Commit a8ec7be

Browse files
arturovtAndrewKushnir
authored andcommitted
refactor(platform-browser): drop unsupported event target error message in production (angular#60016)
Drops unsupported event target error message in production and replaces it with an existing error code. PR Close angular#60016
1 parent 5c70a04 commit a8ec7be

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/platform-browser/src/dom/dom_renderer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,17 @@ class DefaultDomRenderer2 implements Renderer2 {
419419
if (typeof target === 'string') {
420420
target = getDOM().getGlobalEventTarget(this.doc, target);
421421
if (!target) {
422-
throw new Error(`Unsupported event target ${target} for event ${event}`);
422+
throw new RuntimeError(
423+
RuntimeErrorCode.UNSUPPORTED_EVENT_TARGET,
424+
(typeof ngDevMode === 'undefined' || ngDevMode) &&
425+
`Unsupported event target ${target} for event ${event}`,
426+
);
423427
}
424428
}
425429

426430
let wrappedCallback = this.decoratePreventDefault(callback);
427431

428-
if (this.tracingService !== null && this.tracingService.wrapEventListener) {
432+
if (this.tracingService?.wrapEventListener) {
429433
wrappedCallback = this.tracingService.wrapEventListener(target, event, wrappedCallback);
430434
}
431435

0 commit comments

Comments
 (0)