fix(nav): open lightbox when following a search-result link
apply() read the [data-open-slug] marker off the parsed doc after replaceWith() had already reparented #content (and the marker) into the live document, so openSlug came back null and the plate viewer never opened. Read it off the newContent node instead, before the swap. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016h9VwM3YfMpDxaP8KzXcaR
This commit is contained in:
+3
-2
@@ -508,6 +508,9 @@
|
|||||||
|
|
||||||
const newContent = doc.getElementById('content');
|
const newContent = doc.getElementById('content');
|
||||||
const oldContent = document.getElementById('content');
|
const oldContent = document.getElementById('content');
|
||||||
|
// Read the marker off newContent — replaceWith() reparents that node into
|
||||||
|
// the live document, so `doc` no longer contains it afterwards.
|
||||||
|
const openSlug = newContent?.querySelector('[data-open-slug]')?.dataset.openSlug || null;
|
||||||
if (newContent && oldContent) oldContent.replaceWith(newContent);
|
if (newContent && oldContent) oldContent.replaceWith(newContent);
|
||||||
|
|
||||||
const newData = doc.getElementById('roux-data');
|
const newData = doc.getElementById('roux-data');
|
||||||
@@ -515,8 +518,6 @@
|
|||||||
try { POSTS = JSON.parse(newData.textContent) || []; lbBuilt = false; } catch {}
|
try { POSTS = JSON.parse(newData.textContent) || []; lbBuilt = false; } catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const openSlug = doc.querySelector('[data-open-slug]')?.dataset.openSlug || null;
|
|
||||||
|
|
||||||
document.title = doc.title;
|
document.title = doc.title;
|
||||||
syncHeadMeta(doc);
|
syncHeadMeta(doc);
|
||||||
if (push) history.pushState({ url: abs, slug: openSlug || undefined }, '', abs);
|
if (push) history.pushState({ url: abs, slug: openSlug || undefined }, '', abs);
|
||||||
|
|||||||
Reference in New Issue
Block a user