Skip to content

Commit

Permalink
upgrade to idiomorph v0.4.0 and use the new two-pass mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
botandrose-machine committed Dec 23, 2024
1 parent 7ea6805 commit b0dbea1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"chai": "~4.3.4",
"eslint": "^8.13.0",
"express": "^4.18.2",
"idiomorph": "https://github.com/bigskysoftware/idiomorph.git",
"idiomorph": "~0.4.0",
"multer": "^1.4.2",
"rollup": "^2.35.1"
},
Expand Down
6 changes: 6 additions & 0 deletions src/core/morphing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { dispatch } from "../util"
export function morphElements(currentElement, newElement, { callbacks, ...options } = {}) {
Idiomorph.morph(currentElement, newElement, {
...options,
twoPass: true,
callbacks: new DefaultIdiomorphCallbacks(callbacks)
})
}
Expand All @@ -21,6 +22,11 @@ class DefaultIdiomorphCallbacks {
this.#beforeNodeMorphed = beforeNodeMorphed || (() => true)
}

// don't mess with the contents of a permanent node when pantrying
beforeNodePantried = (node) => {
if (node.parentNode?.hasAttribute("data-turbo-permanent")) return false;

Check failure on line 27 in src/core/morphing.js

View workflow job for this annotation

GitHub Actions / build

Extra semicolon
}

beforeNodeAdded = (node) => {
return !(node.id && node.hasAttribute("data-turbo-permanent") && document.getElementById(node.id))
}
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1932,9 +1932,10 @@ iconv-lite@0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"

"idiomorph@https://github.com/bigskysoftware/idiomorph.git":
version "0.3.0"
resolved "https://github.com/bigskysoftware/idiomorph.git#b5115add9f7ab04c04af0624385540dff04e0735"
idiomorph@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/idiomorph/-/idiomorph-0.4.0.tgz#ba63a7a73cf6b8db74acec6e22b7c98341e7d548"
integrity sha512-VdXFpZOTXhLatJmhCWJR5oQKLXT01O6sFCJqT0/EqG71C4tYZdPJ5etvttwWsT2WKRYWz160XkNr1DUqXNMZHg==

ieee754@^1.1.13:
version "1.2.1"
Expand Down

0 comments on commit b0dbea1

Please sign in to comment.