mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-09 09:00:34 +08:00
fix(select): force visual update in IE
IE9, IE10 and IE11 would always show the first <option> as selected when the user moves from a null <option> to a non-null one in a non-null <select>. Even though the model was being updated correctly, visually, the first <option> always appeared selected. Setting the `selected` property twice in a row seems to fix it in all the three versions mentioned above. Closes #7692 Closes #8158
This commit is contained in:
@@ -540,6 +540,12 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
// lastElement.prop('selected') provided by jQuery has side-effects
|
||||
if (existingOption.selected !== option.selected) {
|
||||
lastElement.prop('selected', (existingOption.selected = option.selected));
|
||||
if (msie) {
|
||||
// See #7692
|
||||
// The selected item wouldn't visually update on IE without this.
|
||||
// Tested on Win7: IE9, IE10 and IE11. Future IEs should be tested as well
|
||||
lastElement.prop('selected', existingOption.selected);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// grow elements
|
||||
|
||||
Reference in New Issue
Block a user