Skip to content

Commit 005f66f

Browse files
committed
fix reloading
1 parent 0805398 commit 005f66f

File tree

1 file changed

+13
-6
lines changed
  • scaladoc/resources/dotty_res/scripts

1 file changed

+13
-6
lines changed

scaladoc/resources/dotty_res/scripts/ux.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,21 @@ function attachAllListeners() {
5656
$.get(href, function (data) {
5757
const html = $.parseHTML(data)
5858
const title = html.find(node => node.nodeName === "TITLE").innerText
59-
const divHtml = html.find(node => node.nodeName === "DIV").innerHTML
59+
const bodyDiv = html.find(node => node.nodeName === "DIV")
60+
const { children } = document.body.firstChild
6061
if (window.history.state === null) {
6162
window.history.replaceState({
62-
html: document.body.firstChild.innerHTML,
63+
leftColumn: children[3].innerHTML,
64+
mainDiv: children[6].innerHTML,
6365
title: window.title,
6466
}, '')
6567
}
6668
window.title = title
67-
window.history.pushState({ html: divHtml, title }, '', href)
68-
document.body.firstChild.innerHTML = divHtml
69+
const leftColumn = bodyDiv.children[3].innerHTML
70+
const mainDiv = bodyDiv.children[6].innerHTML
71+
window.history.pushState({ leftColumn, mainDiv, title }, '', href)
72+
children[3].innerHTML = leftColumn
73+
children[6].innerHTML = mainDiv
6974
attachAllListeners()
7075
})
7176
})
@@ -192,9 +197,11 @@ window.addEventListener("DOMContentLoaded", () => {
192197
});
193198

194199
window.addEventListener('popstate', e => {
195-
const { html, title } = e.state
200+
const { leftColumn, mainDiv, title } = e.state
196201
window.title = title
197-
document.body.firstChild.innerHTML = html
202+
const { children } = document.body.firstChild
203+
children[3].innerHTML = leftColumn
204+
children[6].innerHTML = mainDiv
198205
attachAllListeners()
199206
})
200207

0 commit comments

Comments
 (0)