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 @@ ...@@ -151,10 +151,17 @@
151 151
152 attributeBinding = function(attr) { 152 attributeBinding = function(attr) {
153 return function(el, value) { 153 return function(el, value) {
154 if (value) { 154 switch (attr) {
155 return el.setAttribute(attr, value); 155 case 'checked':
156 } else { 156 el.setAttribute('checked', value);
157 return el.removeAttribute(attr); 157 el.checked = value;
158 return el.defaultChecked = value;
159 default:
160 if (value) {
161 return el.setAttribute(attr, value);
162 } else {
163 return el.removeAttribute(attr);
164 }
158 } 165 }
159 }; 166 };
160 }; 167 };
......
...@@ -86,7 +86,16 @@ getInputValue = (el) -> ...@@ -86,7 +86,16 @@ getInputValue = (el) ->
86 # Returns an attribute binding routine for the specified attribute. This is what 86 # Returns an attribute binding routine for the specified attribute. This is what
87 # `registerBinding` falls back to when there is no routine for the binding type. 87 # `registerBinding` falls back to when there is no routine for the binding type.
88 attributeBinding = (attr) -> (el, value) -> 88 attributeBinding = (attr) -> (el, value) ->
89 if value then el.setAttribute attr, value else el.removeAttribute attr 89 switch attr
90 when 'checked'
91 el.setAttribute( 'checked', value )
92 el.checked = value
93 el.defaultChecked = value
94 else
95 if value
96 el.setAttribute attr, value
97 else
98 el.removeAttribute attr
90 99
91 # Returns a state binding routine for the specified attribute. Can optionally be 100 # Returns a state binding routine for the specified attribute. Can optionally be
92 # negatively evaluated. This is used to build a lot of the core state binding 101 # negatively evaluated. This is used to build a lot of the core state binding
......