mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
fix(directive): ng:options incorrectly re-grew options on datasource change
Closes #464
This commit is contained in:
parent
f3456dc282
commit
c348f2cad6
3 changed files with 23 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
- Issue #449: [ng:options] should support binding to a property of an item.
|
- Issue #449: [ng:options] should support binding to a property of an item.
|
||||||
|
- Issue #464: [ng:options] incorrectly re-grew options on datasource change
|
||||||
|
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
- no longer support MMMMM in filter.date as we need to follow UNICODE LOCALE DATA formats.
|
- no longer support MMMMM in filter.date as we need to follow UNICODE LOCALE DATA formats.
|
||||||
|
|
|
||||||
|
|
@ -783,10 +783,13 @@ angularWidget('select', function(element){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fragment) select.append(jqLite(fragment));
|
if (fragment) {
|
||||||
|
select.append(jqLite(fragment));
|
||||||
|
}
|
||||||
// shrink children
|
// shrink children
|
||||||
while(optionElements.length > index) {
|
while(optionElements.length > index) {
|
||||||
optionElements.pop().remove();
|
optionElements.pop().remove();
|
||||||
|
optionTexts.pop();
|
||||||
delete lastSelectValue[optionElements.length];
|
delete lastSelectValue[optionElements.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -672,6 +672,24 @@ describe("widget", function(){
|
||||||
expect(select.find('option').length).toEqual(1); // we add back the special empty option
|
expect(select.find('option').length).toEqual(1); // we add back the special empty option
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should shrink and then grow list', function(){
|
||||||
|
createSingleSelect();
|
||||||
|
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
|
||||||
|
scope.selected = scope.values[0];
|
||||||
|
scope.$eval();
|
||||||
|
expect(select.find('option').length).toEqual(3);
|
||||||
|
|
||||||
|
scope.values = [{name:'1'}, {name:'2'}];
|
||||||
|
scope.selected = scope.values[0];
|
||||||
|
scope.$eval();
|
||||||
|
expect(select.find('option').length).toEqual(2);
|
||||||
|
|
||||||
|
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
|
||||||
|
scope.selected = scope.values[0];
|
||||||
|
scope.$eval();
|
||||||
|
expect(select.find('option').length).toEqual(3);
|
||||||
|
});
|
||||||
|
|
||||||
it('should update list', function(){
|
it('should update list', function(){
|
||||||
createSingleSelect();
|
createSingleSelect();
|
||||||
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
|
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue