pull/1548/head
Rich Harris 7 years ago
parent 7b2a87823a
commit 2d760b3c5e

@ -473,7 +473,9 @@ export default class Element extends Node {
});
}
if (checkTypeAttribute() !== 'checkbox') {
const type = checkTypeAttribute();
if (type !== 'checkbox' && type !== 'radio') {
component.error(binding, {
code: `invalid-binding`,
message: `'${name}' binding can only be used with <input type="checkbox">`

@ -20,7 +20,26 @@ export default {
<p>foo false</p>
<p>bar true</p>
<p>baz false</p>`,
<p>baz false</p>
`,
ssrHtml: `
<label>
<input type="radio" name="x"> foo
</label>
<label>
<input type="radio" name="x" checked> bar
</label>
<label>
<input type="radio" name="x"> baz
</label>
<p>foo false</p>
<p>bar true</p>
<p>baz false</p>
`,
test(assert, component, target, window) {
const inputs = target.querySelectorAll('input');
@ -31,6 +50,7 @@ export default {
const event = new window.Event('change');
inputs[0].checked = true;
assert.equal(inputs[1].checked, false);
inputs[0].dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `

Loading…
Cancel
Save