fix: update to astro-island

This commit is contained in:
Nate Moore 2022-08-19 12:42:13 -04:00
parent 068c706bbb
commit 045d7bb73f

View file

@ -5,7 +5,7 @@ export default () =>
beforeDiff(doc) { beforeDiff(doc) {
for (const island of doc.querySelectorAll('astro-root')) { for (const island of doc.querySelectorAll('astro-root')) {
const uid = island.getAttribute('uid'); const uid = island.getAttribute('uid');
const current = document.querySelector(`astro-root[uid="${uid}"]`); const current = document.querySelector(`astro-island[uid="${uid}"]`);
if (current) { if (current) {
current.dataset.persist = true; current.dataset.persist = true;
island.replaceWith(current); island.replaceWith(current);
@ -13,9 +13,9 @@ export default () =>
} }
}, },
afterDiff() { afterDiff() {
for (const island of document.querySelectorAll('astro-root')) { for (const island of document.querySelectorAll('astro-island')) {
delete island.dataset.persist; delete island.dataset.persist;
} }
window.dispatchEvent(new CustomEvent('astro:locationchange')); window.dispatchEvent(new CustomEvent('astro:hydrate'));
}, },
}); });