Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7852b3f

Browse files
committedNov 13, 2014
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` attribute too. Closes #9621
1 parent 071939b commit 7852b3f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-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+
msie && lastElement.attr('label', existingOption.label);
626627
}
627628
if (existingOption.id !== option.id) {
628629
lastElement.val(existingOption.id = option.id);
@@ -653,6 +654,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
653654
.prop('selected', option.selected)
654655
.attr('selected', option.selected)
655656
.text(option.label);
657+
msie && element.attr('label', option.label);
656658
}
657659

658660
existingOptions.push(existingOption = {

‎test/ng/directive/selectSpec.js

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

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

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

0 commit comments

Comments
 (0)
This repository has been archived.