From adb6255d5d449d611bfd75da0cfd6183d44817a5 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 9 Apr 2019 17:15:45 +0200 Subject: [PATCH] Do not crash if element to remove is not found --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 91df7a137..f2e84bd75 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -53,7 +53,7 @@ module ApplicationHelper script = "(function() {"; script << "var el = document.querySelector('#{selector}');" method = (inner ? "el.innerHTML = ''" : "el.parentNode.removeChild(el)") - script << "setTimeout(function() { #{method}; }, #{timeout});"; + script << "if (el) { setTimeout(function() { #{method}; }, #{timeout}); }"; script << "})();" # rubocop:disable Rails/OutputSafety raw(script);