857194e0 by Ryan Funduk

`setAttribute` doesn't correctly change checked state.

If the user changes the checked state of a checkbox input, `setAttribute`
will stop updating the UI. It appears that internally the state is set
but the interface doesn't match.

Fix is to use a more thorough approach for the checked case, somewhat like
`getInputValue` already does.
1 parent 713507c2
......@@ -151,10 +151,17 @@
attributeBinding = function(attr) {
return function(el, value) {
if (value) {
return el.setAttribute(attr, value);
} else {
return el.removeAttribute(attr);
switch (attr) {
case 'checked':
el.setAttribute('checked', value);
el.checked = value;
return el.defaultChecked = value;
default:
if (value) {
return el.setAttribute(attr, value);
} else {
return el.removeAttribute(attr);
}
}
};
};
......
......@@ -86,7 +86,16 @@ getInputValue = (el) ->
# Returns an attribute binding routine for the specified attribute. This is what
# `registerBinding` falls back to when there is no routine for the binding type.
attributeBinding = (attr) -> (el, value) ->
if value then el.setAttribute attr, value else el.removeAttribute attr
switch attr
when 'checked'
el.setAttribute( 'checked', value )
el.checked = value
el.defaultChecked = value
else
if value
el.setAttribute attr, value
else
el.removeAttribute attr
# Returns a state binding routine for the specified attribute. Can optionally be
# negatively evaluated. This is used to build a lot of the core state binding
......