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

Commit 6604c23

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 195deca commit 6604c23

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
@@ -623,6 +623,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
623623
updateLabelMap(labelMap, existingOption.label, false);
624624
updateLabelMap(labelMap, option.label, true);
625625
lastElement.text(existingOption.label = option.label);
626+
lastElement.prop('label', existingOption.label);
626627
}
627628
if (existingOption.id !== option.id) {
628629
lastElement.val(existingOption.id = option.id);
@@ -652,6 +653,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
652653
.val(option.id)
653654
.prop('selected', option.selected)
654655
.attr('selected', option.selected)
656+
.prop('label', option.label)
655657
.text(option.label);
656658
}
657659

test/ng/directive/selectSpec.js

+17
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,23 @@ describe('select', function() {
13201320
expect(scope.selected).toBe(scope.values[0]);
13211321
});
13221322

1323+
// bug fix #9621
1324+
it('should update the label property', function() {
1325+
// ng-options="value.name for value in values"
1326+
// ng-model="selected"
1327+
createSingleSelect();
1328+
1329+
scope.$apply(function() {
1330+
scope.values = [{name: 'A'}, {name: 'B'}, {name: 'C'}];
1331+
scope.selected = scope.values[0];
1332+
});
1333+
1334+
var options = element.find('option');
1335+
expect(options.eq(0).prop('label')).toEqual('A');
1336+
expect(options.eq(1).prop('label')).toEqual('B');
1337+
expect(options.eq(2).prop('label')).toEqual('C');
1338+
});
1339+
13231340
describe('binding', function() {
13241341

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

0 commit comments

Comments
 (0)