Skip to content

Commit 9a2f8e1

Browse files
refact(select): don't recreate selectedSet on every digest loop
In the case of a "multiple" select, the model value is an array, changes to which don't get picked up by NgModelController as it only looks for object identity change. We were rebuilding the `selectedSet` (a hash map of selected items) from the modelValue on every turn of the digest. This is not needed as we can simply use `$watchCollection` directly on the `$modelValue` instead.
1 parent d2f8f25 commit 9a2f8e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ng/directive/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
415415

416416
scope.$watchCollection(valuesFn, render);
417417
if ( multiple ) {
418-
scope.$watchCollection(getSelectedSet, render);
418+
scope.$watchCollection(function() { return ctrl.$modelValue; }, render);
419419
}
420420

421421
function getSelectedSet() {

0 commit comments

Comments
 (0)