diff options
| author | Jeff Balboni | 2014-01-26 16:17:36 -0500 | 
|---|---|---|
| committer | Caitlin Potter | 2014-03-20 17:27:02 -0400 | 
| commit | dc149de9364c66b988f169f67cad39577ba43434 (patch) | |
| tree | ecc24f8c3de29df8ff34d620d53feb61aca67ec3 /src/ng/directive/select.js | |
| parent | 320f6d1214a67fa337743af1c881c837a01629f4 (diff) | |
| download | angular.js-dc149de9364c66b988f169f67cad39577ba43434.tar.bz2 | |
fix(select): avoid checking option element selected properties in render
In Firefox, hovering over an option in an open select menu updates the selected property of option
elements. This means that when a render is triggered by the digest cycle, and the list of options
is being rendered, the selected properties are reset to the values from the model and the option
hovered over changes. This fix changes the code to only use DOM elements' selected properties in a
comparison when a change event has been fired. Otherwise, the internal new and existing option
arrays are used.
Closes #2448
Closes #5994
Closes #6769
Diffstat (limited to 'src/ng/directive/select.js')
| -rw-r--r-- | src/ng/directive/select.js | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 0b562cca..628d2177 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -394,6 +394,12 @@ var selectDirective = ['$compile', '$parse', function($compile,   $parse) {                    value = valueFn(scope, locals);                  }                } +              // Update the null option's selected property here so $render cleans it up correctly +              if (optionGroupsCache[0].length > 1) { +                if (optionGroupsCache[0][1].id !== key) { +                  optionGroupsCache[0][1].selected = false; +                } +              }              }              ctrl.$setViewValue(value);            }); @@ -531,7 +537,7 @@ var selectDirective = ['$compile', '$parse', function($compile,   $parse) {                    lastElement.val(existingOption.id = option.id);                  }                  // lastElement.prop('selected') provided by jQuery has side-effects -                if (lastElement[0].selected !== option.selected) { +                if (existingOption.selected !== option.selected) {                    lastElement.prop('selected', (existingOption.selected = option.selected));                  }                } else { | 
