From 73eb5821cc24f6941b21d07ced3e0c0bc05a9da8 Mon Sep 17 00:00:00 2001 From: Rick Huynh Date: Thu, 10 Apr 2014 20:29:57 -0500 Subject: [PATCH 1/2] Prevent restoring focus to last element if none exist Fixed a null pointer exception when trying to restore focus to the last element where that element doesn't exist. --- src/alertify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alertify.js b/src/alertify.js index 5e6c167e..9682b1a5 100644 --- a/src/alertify.js +++ b/src/alertify.js @@ -419,7 +419,7 @@ elCover.className = "alertify-cover alertify-cover-hidden"; // set focus to the last element or body // after the dialog is closed - elCallee.focus(); + elCallee ? elCallee.focus() : null; } }, From 1a31aaeb37068b35d15cf36c8b16a2b0b5bc59a0 Mon Sep 17 00:00:00 2001 From: Rick Huynh Date: Thu, 10 Apr 2014 20:52:42 -0500 Subject: [PATCH 2/2] Restructure code to pass jslint --- src/alertify.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/alertify.js b/src/alertify.js index 9682b1a5..e914a456 100644 --- a/src/alertify.js +++ b/src/alertify.js @@ -419,7 +419,9 @@ elCover.className = "alertify-cover alertify-cover-hidden"; // set focus to the last element or body // after the dialog is closed - elCallee ? elCallee.focus() : null; + if (elCallee) { + elCallee.focus(); + } } },