Skip to content

Commit

Permalink
swapfunctions update
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp committed Sep 19, 2024
1 parent 486aeae commit 0ed90fd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/swap-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function swapBodyElement(newElement, oldElement) {
const newEl = newElement.querySelector(`[${PERSIST_ATTR}="${id}"]`);
if (newEl) {
newEl.replaceWith(el);
if (newEl.localName === "astro-island" && shouldCopyProps(el)) {
if (newEl.localName === "astro-island" && shouldCopyProps(el) && !isSameProps(el, newEl)) {
el.setAttribute("ssr", "");
el.setAttribute("props", newEl.getAttribute("props"));
}
Expand Down Expand Up @@ -86,6 +86,9 @@ const shouldCopyProps = (el) => {
const persistProps = el.dataset.astroTransitionPersistProps;
return persistProps == null || persistProps === "false";
};
const isSameProps = (oldEl, newEl) => {
return oldEl.getAttribute("props") === newEl.getAttribute("props");
};
const swapFunctions = {
deselectScripts,
swapRootAttributes,
Expand Down

0 comments on commit 0ed90fd

Please sign in to comment.