diff --git a/app/assets/javascripts/post_histories.js b/app/assets/javascripts/post_histories.js index 4d8c7d985..86c14de82 100644 --- a/app/assets/javascripts/post_histories.js +++ b/app/assets/javascripts/post_histories.js @@ -1,9 +1,14 @@ -$(() => { +document.addEventListener('DOMContentLoaded', () => { const openRelevantEditOnly = () => { - $("details.history-event").prop('open', false); - $(location.hash).prop('open', true); - } + const [[, historyId]] = location.hash.split(':~:'); - window.addEventListener("hashchange", openRelevantEditOnly); + document.querySelectorAll('details.history-event').forEach((el) => { + if (el instanceof HTMLDetailsElement) { + el.open = el.id === historyId; + } + }); + }; + + window.addEventListener('hashchange', openRelevantEditOnly); openRelevantEditOnly(); });