Skip to content

Commit

Permalink
push the correct main section in the history state
Browse files Browse the repository at this point in the history
  • Loading branch information
mercihabam committed Dec 17, 2024
1 parent 7e4063f commit 902a7ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/core/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ async function navigate(url) {
const main = html.match(/<main[^>]*>((.|[\n\r])*)<\/main>/i)[0];
const title = html.match(/<title[^>]*>((.|[\n\r])*)<\/title>/i)[0];

let cyphtMain;
if ($(main).attr('id') === 'cypht-main') {
$('main#cypht-main').replaceWith(main);
cyphtMain = main;
} else {
$('main#cypht-main').replaceWith($(main).find('#cypht-main'));
cyphtMain = $(main).find('#cypht-main').prop('outerHTML');
}
document.title = title.replace(/<[^>]*>/g, '');

Expand All @@ -75,7 +78,7 @@ async function navigate(url) {

const unMountCallback = renderPage(url);

history.pushState({ main, head }, "", url);
history.pushState({ main: cyphtMain, head }, "", url);

if (unMountCallback) {
unMountSubscribers[url] = unMountCallback;
Expand Down

0 comments on commit 902a7ce

Please sign in to comment.