提交 2d760b3c 编写于 作者: R Rich Harris

baby steps

上级 7b2a8782
......@@ -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, `
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册