This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngValue): setting binding to undefined should update the DOM value to an empty string #15605
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6e30312
fix(ngValue): setting binding to undefined should update the DOM valu…
frederikprijck 3ae9f0f
fixup! fix(ngValue): setting binding to undefined should update the D…
frederikprijck db99f4e
fixup! fix(ngValue): setting binding to undefined should update the D…
frederikprijck a8e2cec
fixup! fix(ngValue): setting binding to undefined should update the D…
frederikprijck a29ece6
fixup! fix(ngValue): setting binding to undefined should update the D…
frederikprijck 496a2af
fixup! fix(ngValue): setting binding to undefined should update the D…
frederikprijck ffb122b
fixup! fix(ngValue): setting binding to undefined should update the D…
frederikprijck 011c3a8
fixup! fix(ngValue): setting binding to undefined should update the D…
frederikprijck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4211,6 +4211,26 @@ describe('input', function() { | |
expect(inputElm[0].getAttribute('value')).toBe('something'); | ||
}); | ||
|
||
it('should clear the "dom" value property and attribute when the value is undefined', function() { | ||
var inputElm = helper.compileInput('<input type="text" ng-value="value">'); | ||
|
||
$rootScope.$apply('value = "something"'); | ||
|
||
expect(inputElm[0].value).toBe('something'); | ||
expect(inputElm[0].getAttribute('value')).toBe('something'); | ||
|
||
$rootScope.$apply(function() { | ||
delete $rootScope.value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: This could be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not going to fix this nit as I prefer |
||
}); | ||
|
||
expect(inputElm[0].value).toBe(''); | ||
// Support: IE 9-11 | ||
// In IE it is not possible to remove the `value` attribute from an input element. | ||
if (!msie) { | ||
expect(inputElm[0].getAttribute('value')).toBeNull(); | ||
} | ||
}); | ||
|
||
they('should update the $prop "value" property and attribute after the bound expression changes', { | ||
input: '<input type="text" ng-value="value">', | ||
textarea: '<textarea ng-value="value"></textarea>' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good idea to add a comment here explaining the IE9 issue. Something like: