Skip to content

Commit

Permalink
remove uneeded method call
Browse files Browse the repository at this point in the history
  • Loading branch information
anjmao committed Jun 12, 2018
1 parent cc11fa3 commit a20caca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ng-select/items-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions src/ng-select/selection-model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NgOption } from './ng-select.types';
import { isDefined } from './value-utils';

export class SelectionModel {
private _selected: NgOption[] = [];
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit a20caca

Please sign in to comment.