Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(view-slot): add null check to removeAt #624

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/view-slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<View> {
remove(view: View, returnToCache?: boolean, skipAnimation?: boolean): void | Promise<View> | void{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR is getting merged, lets fix the return type of .remove, it should be the same as of .removeAt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return this.removeAt(this.children.indexOf(view), returnToCache, skipAnimation);
}

Expand Down Expand Up @@ -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<View> {
removeAt(index: number, returnToCache?: boolean, skipAnimation?: boolean): View | Promise<View> | void {
let view = this.children[index];

if(!view) {
return;
}

let removeAction = () => {
index = this.children.indexOf(view);
view.removeNodes();
Expand Down