Skip to content

Commit 578ef87

Browse files
authored
Merge pull request #1928 from codidact/0valt/1925/post-history-hashes
Account for text fragments when autoexpanding post history items
2 parents 44f1d22 + f09e760 commit 578ef87

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
$(() => {
1+
document.addEventListener('DOMContentLoaded', () => {
22
const openRelevantEditOnly = () => {
3-
$("details.history-event").prop('open', false);
4-
$(location.hash).prop('open', true);
5-
}
3+
const [[, historyId]] = location.hash.split(':~:');
64

7-
window.addEventListener("hashchange", openRelevantEditOnly);
5+
document.querySelectorAll('details.history-event').forEach((el) => {
6+
if (el instanceof HTMLDetailsElement) {
7+
el.open = el.id === historyId;
8+
}
9+
});
10+
};
11+
12+
window.addEventListener('hashchange', openRelevantEditOnly);
813
openRelevantEditOnly();
914
});

0 commit comments

Comments
 (0)