Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 61871da

Browse files
Erin Altenhof-Longpetebacondarwin
Erin Altenhof-Long
authored andcommitted
revert(select): avoid checking option element selected properties in render
This reverts commit dc149de. That commit fixes a bug caused by Firefox updating `select.value` on hover. However, it causes other bugs with select including the issue described in #7715. This issue details how selects with a blank disabled option skip to the second option. We filed a bug with Firefox for the problematic behavior the reverted commit addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1039047, and alternate Angular fixes are being investigated. Closes #7715 #7855
1 parent 9ee0755 commit 61871da

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

src/ng/directive/select.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,6 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
395395
value = valueFn(scope, locals);
396396
}
397397
}
398-
// Update the null option's selected property here so $render cleans it up correctly
399-
if (optionGroupsCache[0].length > 1) {
400-
if (optionGroupsCache[0][1].id !== key) {
401-
optionGroupsCache[0][1].selected = false;
402-
}
403-
}
404398
}
405399
ctrl.$setViewValue(value);
406400
});
@@ -538,7 +532,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
538532
lastElement.val(existingOption.id = option.id);
539533
}
540534
// lastElement.prop('selected') provided by jQuery has side-effects
541-
if (existingOption.selected !== option.selected) {
535+
if (lastElement[0].selected !== option.selected) {
542536
lastElement.prop('selected', (existingOption.selected = option.selected));
543537
if (msie) {
544538
// See #7692

test/ng/directive/selectSpec.js

-21
Original file line numberDiff line numberDiff line change
@@ -733,27 +733,6 @@ describe('select', function() {
733733
expect(sortedHtml(options[2])).toEqual('<option value="1">3</option>');
734734
});
735735

736-
it('should not update selected property of an option element on digest with no change event',
737-
function() {
738-
createSingleSelect();
739-
740-
scope.$apply(function() {
741-
scope.values = [{name: 'A'}, {name: 'B'}, {name: 'C'}];
742-
scope.selected = scope.values[0];
743-
});
744-
745-
var options = element.find('option');
746-
var optionToSelect = options.eq(1);
747-
748-
expect(optionToSelect.text()).toBe('B');
749-
750-
optionToSelect.prop('selected', true);
751-
scope.$digest();
752-
753-
expect(optionToSelect.prop('selected')).toBe(true);
754-
expect(scope.selected).toBe(scope.values[0]);
755-
});
756-
757736
describe('binding', function() {
758737

759738
it('should bind to scope value', function() {

0 commit comments

Comments
 (0)