提交 0820d136 编写于 作者: J Johan Preynat

Force re-parsing HTML after history update to set correct URLs in Safari

上级 96c50dad
...@@ -83,9 +83,9 @@ function handleNavigation(relativeUrl, push) { ...@@ -83,9 +83,9 @@ function handleNavigation(relativeUrl, push) {
return '<' + b + 'div' + ( b ? '' : ' data-element="' + c + '"' ) + d + '>'; return '<' + b + 'div' + ( b ? '' : ' data-element="' + c + '"' ) + d + '>';
}); });
var $page = $(html); var $page = $(html),
var $pageHead = $page.find('[data-element=head]'); $pageBody = $page.find('.book'),
var $pageBody = $page.find('.book'); $pageHead;
// We only use history.pushState for pages generated with GitBook // We only use history.pushState for pages generated with GitBook
if ($pageBody.length === 0) { if ($pageBody.length === 0) {
...@@ -100,6 +100,11 @@ function handleNavigation(relativeUrl, push) { ...@@ -100,6 +100,11 @@ function handleNavigation(relativeUrl, push) {
}, null, responseURL); }, null, responseURL);
} }
// Force reparsing HTML to prevent wrong URLs in Safari
$page = $(html);
$pageHead = $page.find('[data-element=head]');
$pageBody = $page.find('.book');
// Merge heads // Merge heads
// !! Warning !!: we only update necessary portions to avoid strange behavior (page flickering etc ...) // !! Warning !!: we only update necessary portions to avoid strange behavior (page flickering etc ...)
...@@ -147,8 +152,8 @@ function handleNavigation(relativeUrl, push) { ...@@ -147,8 +152,8 @@ function handleNavigation(relativeUrl, push) {
return loading.show( return loading.show(
promise promise
.fail(function (e) { .fail(function (e) {
console.log(e); console.log(e); // eslint-disable-line no-console
//location.href = relativeUrl; // location.href = relativeUrl;
}) })
); );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册