From 8de515e4f7ad2b3b4308ae00e810cdaa40428b6f Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Tue, 24 Jan 2017 16:25:34 +0000 Subject: [PATCH 1/2] allow list syntax for clear() since the usage of `clear([toast])` as optional syntax is confusing to people --- src/toastr.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/toastr.js b/src/toastr.js index 24b126c..c84da6b 100644 --- a/src/toastr.js +++ b/src/toastr.js @@ -39,11 +39,14 @@ if (arguments.length === 1 && !toast) { return; } if (toast) { - remove(toast.toastId); - } else { - for (var i = 0; i < toasts.length; i++) { - remove(toasts[i].toastId); + if (!Array.isArray(toast)) { + toast = [ toast ]; } + } else { + toast = toasts; + } + for (var i = 0; i < toast.length; i++) { + remove(toast[i].toastId); } } From b95f84c97a7c47ea13970e6f6ed9861011cd8b3e Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Tue, 24 Jan 2017 16:27:12 +0000 Subject: [PATCH 2/2] clear the HTML of toast on clear seems the destroy call is not always immediate --- src/toastr.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/toastr.js b/src/toastr.js index c84da6b..d226f23 100644 --- a/src/toastr.js +++ b/src/toastr.js @@ -86,6 +86,9 @@ if (toast.scope.options.onHidden) { toast.scope.options.onHidden(!!wasClicked, toast); } + if (toast.el) { + toast.el.html(""); + } toast.scope.$destroy(); var index = toasts.indexOf(toast); delete openToasts[toast.scope.message];