@@ -257,6 +257,43 @@ describe('DomSync', () => {
257
257
expect ( newNodes [ 2 ] ) . toBe ( origRoot2 ) ;
258
258
expect ( newNodes [ 2 ] . childNodes [ 0 ] ) . toBe ( anotherChildWillRetain ) ;
259
259
} ) ;
260
+
261
+ test ( 'should update input element value when not modified by user' , ( ) => {
262
+ // Arrange
263
+ const destination = makeExistingContent (
264
+ `<input value='original'>` ) ;
265
+ const newContent = makeNewContent (
266
+ `<input value='changed'>` ) ;
267
+ const destinationNode = toNodeArray ( destination ) [ 0 ] as HTMLInputElement ;
268
+
269
+ // Act
270
+ synchronizeDomContent ( destination , newContent ) ;
271
+
272
+ // Assert
273
+ expect ( destinationNode . value ) . toEqual ( 'changed' ) ;
274
+ expect ( destinationNode . getAttribute ( 'value' ) ) . toEqual ( 'changed' ) ;
275
+ } ) ;
276
+
277
+ test ( 'should not update input element value when modified by user' , ( ) => {
278
+ // Arrange
279
+ const destination = makeExistingContent (
280
+ `<input value='original'>` ) ;
281
+ const newContent = makeNewContent (
282
+ `<input value='changed'>` ) ;
283
+ const destinationNode = toNodeArray ( destination ) [ 0 ] as HTMLInputElement ;
284
+ destinationNode . value = 'edited by user' ;
285
+
286
+ // Act
287
+ synchronizeDomContent ( destination , newContent ) ;
288
+
289
+ // Assert
290
+ // While we do write a new attribute value, we do *not* overwrite the 'value'
291
+ // property, so any user-performed edits will not be overwritten. This happens automatically
292
+ // without any explicit implementation logic, but since it's the behavior we want, this test
293
+ // is here to detect if we ever regress this behavior.
294
+ expect ( destinationNode . value ) . toEqual ( 'edited by user' ) ;
295
+ expect ( destinationNode . getAttribute ( 'value' ) ) . toEqual ( 'changed' ) ;
296
+ } ) ;
260
297
} ) ;
261
298
262
299
function makeExistingContent ( html : string ) : CommentBoundedRange {
0 commit comments