fail validation if bound <select> has dynamic multiple attribute - fixes #1270

pull/1313/head
Rich-Harris 7 years ago
parent 8717ff8c3c
commit dfc8462d98

@ -102,7 +102,20 @@ export default function validateElement(
);
}
checkTypeAttribute(validator, node);
if (node.name === 'select') {
const attribute = node.attributes.find(
(attribute: Node) => attribute.name === 'multiple'
);
if (attribute && isDynamic(attribute)) {
validator.error(
`'multiple' attribute cannot be dynamic if select uses two-way binding`,
attribute
);
}
} else {
checkTypeAttribute(validator, node);
}
} else if (name === 'checked' || name === 'indeterminate') {
if (node.name !== 'input') {
validator.error(

@ -0,0 +1,12 @@
[{
"message": "'multiple' attribute cannot be dynamic if select uses two-way binding",
"loc": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 28
},
"pos": 19
}]

@ -0,0 +1,5 @@
<select bind:value :multiple>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
Loading…
Cancel
Save