Skip to content

Commit

Permalink
fix(select): force visual update in IE
Browse files Browse the repository at this point in the history
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 angular#7692
Closes angular#8158
  • Loading branch information
rodyhaddad authored and Cameron Knight committed Jul 16, 2014
1 parent 2be5332 commit a99bdba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ng/directive/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,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
Expand Down

0 comments on commit a99bdba

Please sign in to comment.