Do not crash if element to remove is not found
This commit is contained in:
parent
d61db76039
commit
adb6255d5d
1 changed files with 1 additions and 1 deletions
|
@ -53,7 +53,7 @@ module ApplicationHelper
|
||||||
script = "(function() {";
|
script = "(function() {";
|
||||||
script << "var el = document.querySelector('#{selector}');"
|
script << "var el = document.querySelector('#{selector}');"
|
||||||
method = (inner ? "el.innerHTML = ''" : "el.parentNode.removeChild(el)")
|
method = (inner ? "el.innerHTML = ''" : "el.parentNode.removeChild(el)")
|
||||||
script << "setTimeout(function() { #{method}; }, #{timeout});";
|
script << "if (el) { setTimeout(function() { #{method}; }, #{timeout}); }";
|
||||||
script << "})();"
|
script << "})();"
|
||||||
# rubocop:disable Rails/OutputSafety
|
# rubocop:disable Rails/OutputSafety
|
||||||
raw(script);
|
raw(script);
|
||||||
|
|
Loading…
Add table
Reference in a new issue