File tree Expand file tree Collapse file tree 4 files changed +19
-11
lines changed
Expand file tree Collapse file tree 4 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 3333 if ( params . get ( "using" ) . includes ( "morphdom" ) ) {
3434 morphdom ( document . body . firstElementChild , end ) ;
3535 } else {
36- Idiomorph . morph ( document . body . firstElementChild , end , { keepInputValues } ) ;
36+ Idiomorph . morph ( document . body . firstElementChild , end , {
37+ keepInputValues,
38+ } ) ;
3739 }
3840 bench . stop ( ) ;
3941 } ) ;
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ if (benchmarks.length === 0) {
1919}
2020
2121benchmarks . forEach ( ( benchmark ) => {
22- const keepInputValues = process . env . KEEP_INPUT_VALUES === "true" ? "&keepInputValues=true" : "" ;
22+ const keepInputValues =
23+ process . env . KEEP_INPUT_VALUES === "true" ? "&keepInputValues=true" : "" ;
2324 const config = {
2425 root : ".." ,
2526 benchmarks : [
Original file line number Diff line number Diff line change @@ -689,9 +689,14 @@ var Idiomorph = (function () {
689689 if ( oldElt . getAttribute ( newAttribute . name ) !== newAttribute . value ) {
690690 oldElt . setAttribute ( newAttribute . name , newAttribute . value ) ;
691691 // With keepInputValues, update input.value when value attribute changes
692- if ( ctx . keepInputValues && newAttribute . name === "value" &&
693- oldElt instanceof HTMLInputElement && newElt instanceof HTMLInputElement &&
694- newElt . type !== "file" && ! ignoreValueOfActiveElement ( oldElt , ctx ) ) {
692+ if (
693+ ctx . keepInputValues &&
694+ newAttribute . name === "value" &&
695+ oldElt instanceof HTMLInputElement &&
696+ newElt instanceof HTMLInputElement &&
697+ newElt . type !== "file" &&
698+ ! ignoreValueOfActiveElement ( oldElt , ctx )
699+ ) {
695700 oldElt . value = newElt . value ;
696701 }
697702 }
Original file line number Diff line number Diff line change @@ -745,18 +745,18 @@ describe("Core morphing tests", function () {
745745 let parent = make ( '<div><input value="foo"></div>' ) ;
746746 document . body . append ( parent ) ;
747747 let initial = parent . querySelector ( "input" ) ;
748-
748+
749749 initial . value = "userTyped" ;
750-
750+
751751 let finalSrc = '<input value="newServerValue">' ;
752- Idiomorph . morph ( initial , finalSrc , {
752+ Idiomorph . morph ( initial , finalSrc , {
753753 morphStyle : "outerHTML" ,
754- keepInputValues : true
754+ keepInputValues : true ,
755755 } ) ;
756-
756+
757757 initial . value . should . equal ( "newServerValue" ) ;
758758 initial . getAttribute ( "value" ) . should . equal ( "newServerValue" ) ;
759-
759+
760760 document . body . removeChild ( parent ) ;
761761 } ) ;
762762} ) ;
You can’t perform that action at this time.
0 commit comments