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