@@ -18,13 +18,13 @@ export class SelectionModel<T> {
18
18
/** Keeps track of the deselected options that haven't been emitted by the change event. */
19
19
private _deselectedToEmit : T [ ] = [ ] ;
20
20
21
- /** Keeps track of the selected option that haven't been emitted by the change event. */
21
+ /** Keeps track of the selected options that haven't been emitted by the change event. */
22
22
private _selectedToEmit : T [ ] = [ ] ;
23
23
24
24
/** Cache for the array value of the selected items. */
25
25
private _selected : T [ ] | null ;
26
26
27
- /** Selected value(s) . */
27
+ /** Selected values . */
28
28
get selected ( ) : T [ ] {
29
29
if ( ! this . _selected ) {
30
30
this . _selected = Array . from ( this . _selection . values ( ) ) ;
@@ -37,12 +37,12 @@ export class SelectionModel<T> {
37
37
onChange : Subject < SelectionChange < T > > | null = this . _emitChanges ? new Subject ( ) : null ;
38
38
39
39
constructor (
40
- private _isMulti = false ,
40
+ private _multiple = false ,
41
41
initiallySelectedValues ?: T [ ] ,
42
42
private _emitChanges = true ) {
43
43
44
- if ( initiallySelectedValues ) {
45
- if ( _isMulti ) {
44
+ if ( initiallySelectedValues && initiallySelectedValues . length ) {
45
+ if ( _multiple ) {
46
46
initiallySelectedValues . forEach ( value => this . _markSelected ( value ) ) ;
47
47
} else {
48
48
this . _markSelected ( initiallySelectedValues [ 0 ] ) ;
@@ -111,7 +111,7 @@ export class SelectionModel<T> {
111
111
* Sorts the selected values based on a predicate function.
112
112
*/
113
113
sort ( predicate ?: ( a : T , b : T ) => number ) : void {
114
- if ( this . _isMulti && this . _selected ) {
114
+ if ( this . _multiple && this . _selected ) {
115
115
this . _selected . sort ( predicate ) ;
116
116
}
117
117
}
@@ -136,7 +136,7 @@ export class SelectionModel<T> {
136
136
/** Selects a value. */
137
137
private _markSelected ( value : T ) {
138
138
if ( ! this . isSelected ( value ) ) {
139
- if ( ! this . _isMulti ) {
139
+ if ( ! this . _multiple ) {
140
140
this . _unmarkAll ( ) ;
141
141
}
142
142
@@ -171,7 +171,7 @@ export class SelectionModel<T> {
171
171
* including multiple values while the selection model is not supporting multiple values.
172
172
*/
173
173
private _verifyValueAssignment ( values : T [ ] ) {
174
- if ( values . length > 1 && ! this . _isMulti ) {
174
+ if ( values . length > 1 && ! this . _multiple ) {
175
175
throw getMultipleValuesInSingleSelectionError ( ) ;
176
176
}
177
177
}
0 commit comments