diff --git a/src/ng-select/items-list.ts b/src/ng-select/items-list.ts index 8b320dbbf..150d7af6b 100644 --- a/src/ng-select/items-list.ts +++ b/src/ng-select/items-list.ts @@ -252,7 +252,7 @@ export class ItemsList { private _showSelectedItems(current: NgOption) { this._filteredItems.splice(current.index, 0, current); - if (isDefined(current.parent)) { + if (current.parent) { const parent = current.parent; const alreadyAdded = this._filteredItems.find(x => x === parent); if (!alreadyAdded) { @@ -269,7 +269,7 @@ export class ItemsList { private _hideSelectedItems(current: NgOption) { this._filteredItems = this._filteredItems.filter(x => x !== current); - if (isDefined(current.parent)) { + if (current.parent) { const children = current.parent.children; const selectedChildrenCount = this._countItems(this.selectedItems, x => children.indexOf(x) > -1); if (children.length === selectedChildrenCount) { diff --git a/src/ng-select/selection-model.ts b/src/ng-select/selection-model.ts index a3bf2cda9..9f877ccd6 100644 --- a/src/ng-select/selection-model.ts +++ b/src/ng-select/selection-model.ts @@ -1,5 +1,4 @@ import { NgOption } from './ng-select.types'; -import { isDefined } from './value-utils'; export class SelectionModel { private _selected: NgOption[] = []; @@ -12,7 +11,7 @@ export class SelectionModel { item.selected = true; this._selected.push(item); if (multiple) { - if (isDefined(item.parent)) { + if (item.parent) { this._removeParent(item.parent); const childrenCount = item.parent.children ? item.parent.children.length : 0; const selectedCount = this._selected.filter(x => x.parent === item.parent).length; @@ -29,7 +28,7 @@ export class SelectionModel { this._selected = this._selected.filter(x => x !== item); item.selected = false; if (multiple) { - if (isDefined(item.parent) && item.parent.selected) { + if (item.parent && item.parent.selected) { const children = item.parent.children; this._removeParent(item.parent); this._removeSelectedChildren(children);