From c06af2dd88b088ec6f3ccbdae8a1316584579515 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 23 Mar 2019 08:23:38 -0400 Subject: [PATCH] tidy some binding validation messages (#2300) --- src/compile/nodes/Element.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index 536e1e729a..c0da7ea5c0 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -493,11 +493,12 @@ export default class Element extends Node { }); } - if (check_type_attribute() !== 'checkbox') { - component.error(binding, { - code: `invalid-binding`, - message: `'${name}' binding can only be used with ` - }); + const type = check_type_attribute(); + + if (type !== 'checkbox') { + let message = `'${name}' binding can only be used with `; + if (type === 'radio') message += ` — for , use 'group' binding`; + component.error(binding, { code: `invalid-binding`, message }); } } else if (name === 'group') { if (this.name !== 'input') { @@ -512,14 +513,14 @@ export default class Element extends Node { if (type !== 'checkbox' && type !== 'radio') { component.error(binding, { code: `invalid-binding`, - message: `'checked' binding can only be used with or ` + message: `'group' binding can only be used with or ` }); } } else if (name == 'files') { if (this.name !== 'input') { component.error(binding, { code: `invalid-binding`, - message: `'files' binding acn only be used with ` + message: `'files' is not a valid binding on <${this.name}> elements` }); }