File tree 1 file changed +25
-5
lines changed
1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -260,13 +260,33 @@ pub fn patch_el_details<Ms>(
260
260
} )
261
261
}
262
262
// Remove attributes that aren't in the new vdom.
263
- for name in old. attrs . vals . keys ( ) {
264
- if new. attrs . vals . get ( name ) . is_none ( ) {
263
+ for ( key , old_val ) in & old. attrs . vals {
264
+ if new. attrs . vals . get ( key ) . is_none ( ) {
265
265
// todo get to the bottom of this
266
266
match old_el_ws. dyn_ref :: < web_sys:: Element > ( ) {
267
- Some ( el) => el
268
- . remove_attribute ( name. as_str ( ) )
269
- . expect ( "Removing an attribute" ) ,
267
+ Some ( el) => {
268
+ el. remove_attribute ( key. as_str ( ) )
269
+ . expect ( "Removing an attribute" ) ;
270
+
271
+ // We handle value in the vdom using attributes, but the DOM needs
272
+ // to use set_value or set_checked.
273
+ match key {
274
+ At :: Value => match old_val {
275
+ AtValue :: Some ( _) => crate :: util:: set_value ( old_el_ws, "" ) ,
276
+ _ => Ok ( ( ) ) ,
277
+ } ,
278
+ At :: Checked => match old_val {
279
+ AtValue :: Some ( _) | AtValue :: None => {
280
+ crate :: util:: set_checked ( old_el_ws, false )
281
+ }
282
+ _ => Ok ( ( ) ) ,
283
+ } ,
284
+ _ => Ok ( ( ) ) ,
285
+ }
286
+ . unwrap_or_else ( |err| {
287
+ crate :: error ( err) ;
288
+ } )
289
+ }
270
290
None => {
271
291
crate :: error ( "Minor error on html element (setting attrs)" ) ;
272
292
}
You can’t perform that action at this time.
0 commit comments