@@ -472,6 +472,35 @@ describe('render()', () => {
472472 expect ( scratch . firstChild . spellcheck ) . to . equal ( false ) ;
473473 } ) ;
474474
475+ // Test for preactjs/preact#4340
476+ it ( 'should respect defaultValue in render' , ( ) => {
477+ scratch . innerHTML = '<input value="foo">' ;
478+ render ( < input defaultValue = "foo" /> , scratch ) ;
479+ expect ( scratch . firstChild . value ) . to . equal ( 'foo' ) ;
480+ } ) ;
481+
482+ it ( 'should support subsequent renders w/ defaultValue' , ( ) => {
483+ scratch . innerHTML = '<input value="foo">' ;
484+ render ( < input defaultValue = "foo" value = "bar" /> , scratch ) ;
485+ expect ( scratch . firstChild . value ) . to . equal ( 'bar' ) ;
486+ render ( < input defaultValue = "foo" value = "baz" /> , scratch ) ;
487+ expect ( scratch . firstChild . value ) . to . equal ( 'baz' ) ;
488+ } ) ;
489+
490+ it ( 'should respect defaultChecked in render' , ( ) => {
491+ scratch . innerHTML = '<input checked="true">' ;
492+ render ( < input defaultChecked /> , scratch ) ;
493+ expect ( scratch . firstChild . checked ) . to . equal ( true ) ;
494+ } ) ;
495+
496+ it ( 'should support subsequent renders w/ defaultChecked' , ( ) => {
497+ scratch . innerHTML = '<input checked="true">' ;
498+ render ( < input defaultChecked checked /> , scratch ) ;
499+ expect ( scratch . firstChild . checked ) . to . equal ( true ) ;
500+ render ( < input defaultChecked checked = { false } /> , scratch ) ;
501+ expect ( scratch . firstChild . checked ) . to . equal ( false ) ;
502+ } ) ;
503+
475504 it ( 'should render download attribute' , ( ) => {
476505 render ( < a download = "" /> , scratch ) ;
477506 expect ( scratch . firstChild . getAttribute ( 'download' ) ) . to . equal ( '' ) ;
0 commit comments