Merge pull request #3766 from tchak/fix-sentry-bug

Do not crash if element to remove is not found
This commit is contained in:
Nicolas Bouilleaud 2019-04-09 17:24:27 +02:00 committed by GitHub
commit ca5f31e374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

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

View file

@ -1,2 +1,3 @@
<%= render_flash(timeout: 5000, sticky: true) %>
<%= remove_element("#piece_justificative_#{@champ.id}") %>
<%= show_element("#champs_#{@champ.id}") %>