From ae1b3b4aeb214e5f3a79e23be5a5f3b2679a3475 Mon Sep 17 00:00:00 2001 From: adiguba Date: Sat, 4 Mar 2023 16:26:42 +0100 Subject: [PATCH] error for on:*={handler} --- src/compiler/compile/compiler_errors.ts | 4 ++++ src/compiler/compile/nodes/EventHandler.ts | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/compiler/compile/compiler_errors.ts b/src/compiler/compile/compiler_errors.ts index b869fdfa56..d699b8902b 100644 --- a/src/compiler/compile/compiler_errors.ts +++ b/src/compiler/compile/compiler_errors.ts @@ -297,5 +297,9 @@ export default { invalid_forward_event_alias_any: { code: 'invalid-forward-event-alias-any', message: 'The alias for on:* must be of the following form : "prefix*" or "*suffix"' + }, + invalid_foward_event_any: { + code: 'invalid-forward-event-any', + message: 'The directive on:* cannot be used with an handler' } }; diff --git a/src/compiler/compile/nodes/EventHandler.ts b/src/compiler/compile/nodes/EventHandler.ts index ac759f166f..5872e7e3c5 100644 --- a/src/compiler/compile/nodes/EventHandler.ts +++ b/src/compiler/compile/nodes/EventHandler.ts @@ -92,6 +92,10 @@ export default class EventHandler extends Node { validate() { if (this.expression) { + if (this.name === '*') { + return this.component.error(this, compiler_errors.invalid_foward_event_any); + } + if (this.modifiers.has('passive') && this.modifiers.has('preventDefault')) { return this.component.error(this, compiler_errors.invalid_event_modifier_combination('passive', 'preventDefault')); } @@ -130,12 +134,15 @@ export default class EventHandler extends Node { if (this.aliasCount > 1) { return this.component.error(this, compiler_errors.invalid_forward_event_alias_count); } - if (this.aliasName && valid_modifiers.has(this.aliasName)) { - this.component.warn(this, compiler_warnings.invalid_forward_event_alias); - } - if (this.name === '*' && !is_valid_any_alias_name(this.aliasName)) { - return this.component.error(this, compiler_errors.invalid_forward_event_alias_any); + if (this.aliasName) { + if (this.name === '*' && !is_valid_any_alias_name(this.aliasName)) { + return this.component.error(this, compiler_errors.invalid_forward_event_alias_any); + } + if (valid_modifiers.has(this.aliasName)) { + this.component.warn(this, compiler_warnings.invalid_forward_event_alias); + } } + } }