Merge pull request #403 from widgetic/fix/binding-input-radio-group

Fix: binding input radio group #399
pull/407/head
Rich Harris 9 years ago committed by GitHub
commit 5d697eca65

@ -59,9 +59,7 @@ export default function createBinding ( generator, node, attribute, current, loc
setter = deindent` setter = deindent`
if ( !${local.name}.checked ) return; if ( !${local.name}.checked ) return;
${setter} ${setter}
component._bindingGroups[${bindingGroup}].forEach( function ( input ) { `;
input.checked = false;
});`;
} }
const condition = type === 'checkbox' ? const condition = type === 'checkbox' ?
@ -158,4 +156,4 @@ function getBindingGroup ( generator, current, attribute, keypath ) {
} }
return index; return index;
} }

@ -16,15 +16,15 @@ export default {
<label> <label>
<input type="radio"> Alpha <input type="radio"> Alpha
</label> </label>
<label> <label>
<input type="radio"> Beta <input type="radio"> Beta
</label> </label>
<label> <label>
<input type="radio"> Gamma <input type="radio"> Gamma
</label> </label>
<p>Beta</p>`, <p>Beta</p>`,
test ( assert, component, target, window ) { test ( assert, component, target, window ) {
@ -42,18 +42,22 @@ export default {
<label> <label>
<input type="radio"> Alpha <input type="radio"> Alpha
</label> </label>
<label> <label>
<input type="radio"> Beta <input type="radio"> Beta
</label> </label>
<label> <label>
<input type="radio"> Gamma <input type="radio"> Gamma
</label> </label>
<p>Alpha</p> <p>Alpha</p>
` ); ` );
assert.equal( inputs[0].checked, true );
assert.equal( inputs[1].checked, false );
assert.equal( inputs[2].checked, false );
component.set({ selected: values[2] }); component.set({ selected: values[2] });
assert.equal( inputs[0].checked, false ); assert.equal( inputs[0].checked, false );
assert.equal( inputs[1].checked, false ); assert.equal( inputs[1].checked, false );
@ -63,15 +67,15 @@ export default {
<label> <label>
<input type="radio"> Alpha <input type="radio"> Alpha
</label> </label>
<label> <label>
<input type="radio"> Beta <input type="radio"> Beta
</label> </label>
<label> <label>
<input type="radio"> Gamma <input type="radio"> Gamma
</label> </label>
<p>Gamma</p> <p>Gamma</p>
` ); ` );
} }

Loading…
Cancel
Save