Skip to content

Commit 5d697ec

Browse files
authored
Merge pull request #403 from widgetic/fix/binding-input-radio-group
Fix: binding input radio group #399
2 parents e67c6b7 + 3c9f82a commit 5d697ec

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/generators/dom/visitors/attributes/addElementBinding.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ export default function createBinding ( generator, node, attribute, current, loc
5959
setter = deindent`
6060
if ( !${local.name}.checked ) return;
6161
${setter}
62-
component._bindingGroups[${bindingGroup}].forEach( function ( input ) {
63-
input.checked = false;
64-
});`;
62+
`;
6563
}
6664

6765
const condition = type === 'checkbox' ?
@@ -158,4 +156,4 @@ function getBindingGroup ( generator, current, attribute, keypath ) {
158156
}
159157

160158
return index;
161-
}
159+
}

test/generator/samples/binding-input-radio-group/_config.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ export default {
1616
<label>
1717
<input type="radio"> Alpha
1818
</label>
19-
19+
2020
<label>
2121
<input type="radio"> Beta
2222
</label>
23-
23+
2424
<label>
2525
<input type="radio"> Gamma
2626
</label>
27-
27+
2828
<p>Beta</p>`,
2929

3030
test ( assert, component, target, window ) {
@@ -42,18 +42,22 @@ export default {
4242
<label>
4343
<input type="radio"> Alpha
4444
</label>
45-
45+
4646
<label>
4747
<input type="radio"> Beta
4848
</label>
49-
49+
5050
<label>
5151
<input type="radio"> Gamma
5252
</label>
53-
53+
5454
<p>Alpha</p>
5555
` );
5656

57+
assert.equal( inputs[0].checked, true );
58+
assert.equal( inputs[1].checked, false );
59+
assert.equal( inputs[2].checked, false );
60+
5761
component.set({ selected: values[2] });
5862
assert.equal( inputs[0].checked, false );
5963
assert.equal( inputs[1].checked, false );
@@ -63,15 +67,15 @@ export default {
6367
<label>
6468
<input type="radio"> Alpha
6569
</label>
66-
70+
6771
<label>
6872
<input type="radio"> Beta
6973
</label>
70-
74+
7175
<label>
7276
<input type="radio"> Gamma
7377
</label>
74-
78+
7579
<p>Gamma</p>
7680
` );
7781
}

0 commit comments

Comments
 (0)