diff --git a/src/view-slot.js b/src/view-slot.js index 9e8d2f9b..65976e7e 100644 --- a/src/view-slot.js +++ b/src/view-slot.js @@ -209,7 +209,7 @@ export class ViewSlot { * @param skipAnimation Should the removal animation be skipped? * @return May return a promise if the view removal triggered an animation. */ - remove(view: View, returnToCache?: boolean, skipAnimation?: boolean): void | Promise { + remove(view: View, returnToCache?: boolean, skipAnimation?: boolean): void | Promise | View{ return this.removeAt(this.children.indexOf(view), returnToCache, skipAnimation); } @@ -275,9 +275,13 @@ export class ViewSlot { * @param skipAnimation Should the removal animation be skipped? * @return May return a promise if the view removal triggered an animation. */ - removeAt(index: number, returnToCache?: boolean, skipAnimation?: boolean): View | Promise { + removeAt(index: number, returnToCache?: boolean, skipAnimation?: boolean): View | Promise | void { let view = this.children[index]; + if(!view) { + return; + } + let removeAction = () => { index = this.children.indexOf(view); view.removeNodes();