error for on:*={handler}

pull/8356/head
adiguba 4 years ago
parent b7950e34af
commit ae1b3b4aeb

@ -297,5 +297,9 @@ export default {
invalid_forward_event_alias_any: { invalid_forward_event_alias_any: {
code: '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"' 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'
} }
}; };

@ -92,6 +92,10 @@ export default class EventHandler extends Node {
validate() { validate() {
if (this.expression) { 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')) { if (this.modifiers.has('passive') && this.modifiers.has('preventDefault')) {
return this.component.error(this, compiler_errors.invalid_event_modifier_combination('passive', '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) { if (this.aliasCount > 1) {
return this.component.error(this, compiler_errors.invalid_forward_event_alias_count); return this.component.error(this, compiler_errors.invalid_forward_event_alias_count);
} }
if (this.aliasName && valid_modifiers.has(this.aliasName)) { if (this.aliasName) {
this.component.warn(this, compiler_warnings.invalid_forward_event_alias);
}
if (this.name === '*' && !is_valid_any_alias_name(this.aliasName)) { if (this.name === '*' && !is_valid_any_alias_name(this.aliasName)) {
return this.component.error(this, compiler_errors.invalid_forward_event_alias_any); 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);
}
}
} }
} }

Loading…
Cancel
Save