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

Commit 16833d0

Browse files
fix(select): ensure the label attribute is updated in Internet Explorer
Only changing the `<option>` text value is not enough to trigger a render change in IE. We need to explicit update the `label` property too. Closes #9621 Closes #10042
1 parent 2a8a4e7 commit 16833d0

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/ng/directive/select.js

+2
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
551551
lastElement = existingOption.element;
552552
if (existingOption.label !== option.label) {
553553
lastElement.text(existingOption.label = option.label);
554+
lastElement.prop('label', existingOption.label);
554555
}
555556
if (existingOption.id !== option.id) {
556557
lastElement.val(existingOption.id = option.id);
@@ -580,6 +581,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
580581
.val(option.id)
581582
.prop('selected', option.selected)
582583
.attr('selected', option.selected)
584+
.prop('label', option.label)
583585
.text(option.label);
584586
}
585587

test/ng/directive/selectSpec.js

+17
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,23 @@ describe('select', function() {
847847
expect(scope.selected).toBe(scope.values[0]);
848848
});
849849

850+
// bug fix #9621
851+
it('should update the label property', function() {
852+
// ng-options="value.name for value in values"
853+
// ng-model="selected"
854+
createSingleSelect();
855+
856+
scope.$apply(function() {
857+
scope.values = [{name: 'A'}, {name: 'B'}, {name: 'C'}];
858+
scope.selected = scope.values[0];
859+
});
860+
861+
var options = element.find('option');
862+
expect(options.eq(0).prop('label')).toEqual('A');
863+
expect(options.eq(1).prop('label')).toEqual('B');
864+
expect(options.eq(2).prop('label')).toEqual('C');
865+
});
866+
850867
describe('binding', function() {
851868

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

0 commit comments

Comments
 (0)