Do not crash if element to remove is not found

This commit is contained in:
Paul Chavard 2019-04-09 17:15:45 +02:00
parent d61db76039
commit adb6255d5d

View file

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