File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
packages/angular_devkit/build_angular/src Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -56,8 +56,8 @@ describe('Dev Server Builder HMR', () => {
5656 'src/app/app.component.html' : `
5757 <p>{{title}}</p>
5858
59- <input type="text">
60-
59+ <input class="visible" type="text">
60+ <input type="hidden">
6161 <select>
6262 <option>one</option>
6363 <option>two</option>
@@ -165,7 +165,7 @@ describe('Dev Server Builder HMR', () => {
165165 await page . goto ( url ) ;
166166 expect ( logs ) . toContain ( '[HMR] Waiting for update signal from WDS...' ) ;
167167 await page . evaluate ( ( ) => {
168- document . querySelector ( 'input' ) . value = 'input value' ;
168+ document . querySelector ( 'input.visible ' ) . value = 'input value' ;
169169 document . querySelector ( 'select' ) . value = 'two' ;
170170 } ) ;
171171
@@ -177,7 +177,7 @@ describe('Dev Server Builder HMR', () => {
177177 expect ( logs ) . toContain ( '[NG HMR] Restoring input/textarea values.' ) ;
178178 expect ( logs ) . toContain ( '[NG HMR] Restoring selected options.' ) ;
179179
180- const inputValue = await page . evaluate ( ( ) => document . querySelector ( 'input' ) . value ) ;
180+ const inputValue = await page . evaluate ( ( ) => document . querySelector ( 'input.visible ' ) . value ) ;
181181 expect ( inputValue ) . toBe ( 'input value' ) ;
182182
183183 const selectValue = await page . evaluate ( ( ) => document . querySelector ( 'select' ) . value ) ;
Original file line number Diff line number Diff line change @@ -52,7 +52,8 @@ export default function (mod: any): void {
5252 return ;
5353 }
5454
55- const oldInputs = document . querySelectorAll ( 'input, textarea' ) ;
55+ // Inputs that are hidden should be ignored
56+ const oldInputs = document . querySelectorAll ( 'input:not([type="hidden"]), textarea' ) ;
5657 const oldOptions = document . querySelectorAll ( 'option' ) ;
5758
5859 // Create new application
@@ -160,8 +161,8 @@ function dispatchEvents(element: any): void {
160161}
161162
162163function restoreFormValues ( oldInputs : any [ ] , oldOptions : any [ ] ) : void {
163- // Restore input
164- const newInputs = document . querySelectorAll ( 'input, textarea' ) ;
164+ // Restore input that are not hidden
165+ const newInputs = document . querySelectorAll ( 'input:not([type="hidden"]) , textarea' ) ;
165166 if ( newInputs . length && newInputs . length === oldInputs . length ) {
166167 console . log ( '[NG HMR] Restoring input/textarea values.' ) ;
167168 for ( let index = 0 ; index < newInputs . length ; index ++ ) {
You can’t perform that action at this time.
0 commit comments