File tree 2 files changed +8
-7
lines changed
packages/angular_devkit/build_angular/src
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', () => {
56
56
'src/app/app.component.html' : `
57
57
<p>{{title}}</p>
58
58
59
- <input type="text">
60
-
59
+ <input class="visible" type="text">
60
+ <input type="hidden">
61
61
<select>
62
62
<option>one</option>
63
63
<option>two</option>
@@ -165,7 +165,7 @@ describe('Dev Server Builder HMR', () => {
165
165
await page . goto ( url ) ;
166
166
expect ( logs ) . toContain ( '[HMR] Waiting for update signal from WDS...' ) ;
167
167
await page . evaluate ( ( ) => {
168
- document . querySelector ( 'input' ) . value = 'input value' ;
168
+ document . querySelector ( 'input.visible ' ) . value = 'input value' ;
169
169
document . querySelector ( 'select' ) . value = 'two' ;
170
170
} ) ;
171
171
@@ -177,7 +177,7 @@ describe('Dev Server Builder HMR', () => {
177
177
expect ( logs ) . toContain ( '[NG HMR] Restoring input/textarea values.' ) ;
178
178
expect ( logs ) . toContain ( '[NG HMR] Restoring selected options.' ) ;
179
179
180
- const inputValue = await page . evaluate ( ( ) => document . querySelector ( 'input' ) . value ) ;
180
+ const inputValue = await page . evaluate ( ( ) => document . querySelector ( 'input.visible ' ) . value ) ;
181
181
expect ( inputValue ) . toBe ( 'input value' ) ;
182
182
183
183
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 {
52
52
return ;
53
53
}
54
54
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' ) ;
56
57
const oldOptions = document . querySelectorAll ( 'option' ) ;
57
58
58
59
// Create new application
@@ -160,8 +161,8 @@ function dispatchEvents(element: any): void {
160
161
}
161
162
162
163
function 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' ) ;
165
166
if ( newInputs . length && newInputs . length === oldInputs . length ) {
166
167
console . log ( '[NG HMR] Restoring input/textarea values.' ) ;
167
168
for ( let index = 0 ; index < newInputs . length ; index ++ ) {
You can’t perform that action at this time.
0 commit comments