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);