From 2eef227c0d6b00e1ddc0b87ea0e2300d09780c5f Mon Sep 17 00:00:00 2001 From: Cristian Necula Date: Thu, 23 Mar 2017 14:37:29 +0200 Subject: [PATCH 1/2] (test) assert input's checked status after a DOM 'change' event --- .../binding-input-radio-group/_config.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/generator/samples/binding-input-radio-group/_config.js b/test/generator/samples/binding-input-radio-group/_config.js index e42ef168f6..b557496533 100644 --- a/test/generator/samples/binding-input-radio-group/_config.js +++ b/test/generator/samples/binding-input-radio-group/_config.js @@ -16,15 +16,15 @@ export default { - + - + - +

Beta

`, test ( assert, component, target, window ) { @@ -42,18 +42,22 @@ export default { - + - + - +

Alpha

` ); + assert.equal( inputs[0].checked, true ); + assert.equal( inputs[1].checked, false ); + assert.equal( inputs[2].checked, false ); + component.set({ selected: values[2] }); assert.equal( inputs[0].checked, false ); assert.equal( inputs[1].checked, false ); @@ -63,15 +67,15 @@ export default { - + - + - +

Gamma

` ); } From 3c9f82a7b6c9f9a96d4439c1d9d66760c12517c3 Mon Sep 17 00:00:00 2001 From: Cristian Necula Date: Thu, 23 Mar 2017 17:21:06 +0200 Subject: [PATCH 2/2] (fix:radio-groups) preserve the radio input's checked state after handling a state change Do not manually toggle the input's checked state, the browser already does this for inputs in the same group. https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/group --- src/generators/dom/visitors/attributes/addElementBinding.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/generators/dom/visitors/attributes/addElementBinding.js b/src/generators/dom/visitors/attributes/addElementBinding.js index 98488351d6..769eeb91ff 100644 --- a/src/generators/dom/visitors/attributes/addElementBinding.js +++ b/src/generators/dom/visitors/attributes/addElementBinding.js @@ -59,9 +59,7 @@ export default function createBinding ( generator, node, attribute, current, loc setter = deindent` if ( !${local.name}.checked ) return; ${setter} - component._bindingGroups[${bindingGroup}].forEach( function ( input ) { - input.checked = false; - });`; + `; } const condition = type === 'checkbox' ? @@ -158,4 +156,4 @@ function getBindingGroup ( generator, current, attribute, keypath ) { } return index; -} \ No newline at end of file +}