mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-07 22:37:28 +08:00
fix(ng:options): select correct element when '?'-option was previously selected
Closes #599
This commit is contained in:
committed by
Igor Minar
parent
74379df6c4
commit
ee6af9a978
@@ -384,7 +384,7 @@ angularWidget('select', function(element){
|
||||
if (existingOption.id !== option.id) {
|
||||
lastElement.val(existingOption.id = option.id);
|
||||
}
|
||||
if (existingOption.selected !== option.selected) {
|
||||
if (existingOption.element.selected !== option.selected) {
|
||||
lastElement.prop('selected', (existingOption.selected = option.selected));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -428,6 +428,21 @@ describe('select', function() {
|
||||
expect(select.val()).toEqual('0');
|
||||
expect(select.find('option').length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should select correct input if previously selected option was "?"', function() {
|
||||
createSingleSelect();
|
||||
scope.values = [{name:'A'},{name:'B'}];
|
||||
scope.selected = {};
|
||||
scope.$digest();
|
||||
expect(select.find('option').length).toEqual(3);
|
||||
expect(select.val()).toEqual('?');
|
||||
expect(select.find('option').eq(0).val()).toEqual('?');
|
||||
|
||||
browserTrigger(select.find('option').eq(1));
|
||||
expect(select.val()).toEqual('0');
|
||||
expect(select.find('option').eq(0).prop('selected')).toBeTruthy();
|
||||
expect(select.find('option').length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('on change', function() {
|
||||
@@ -504,7 +519,5 @@ describe('select', function() {
|
||||
expect(scope.selected).toEqual([scope.values[0]]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user