Skip to content

Commit b6fd7a9

Browse files
authored
Add Alpine.morphBetween() (#4629)
* wip * wip * wip * wip * wip * wip * wip * wip
1 parent e363181 commit b6fd7a9

File tree

4 files changed

+494
-90
lines changed

4 files changed

+494
-90
lines changed

packages/docs/src/en/plugins/morph.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,15 @@ By adding keys to each node, we can accomplish this like so:
250250
Now that there are "keys" on the `<li>`s, Morph will match them in both trees and move them accordingly.
251251

252252
You can configure what Morph considers a "key" with the `key:` configuration option. [More on that here](#lifecycle-hooks)
253+
254+
<a name="alpine-morph-between"></a>
255+
## Alpine.morphBetween()
256+
257+
The `Alpine.morphBetween(startMarker, endMarker, newHtml, options)` method allows you to morph a range of DOM nodes between two marker elements based on passed in HTML. This is useful when you want to update only a specific section of the DOM without providing a single root node.
258+
259+
| Parameter | Description |
260+
| --- | --- |
261+
| `startMarker` | A DOM node (typically a comment node) that marks the beginning of the range to morph |
262+
| `endMarker` | A DOM node (typically a comment node) that marks the end of the range to morph |
263+
| `newHtml` | A string of HTML or a DOM element to replace the content between the markers |
264+
| `options` | An object of options (same as `Alpine.morph()`) |

packages/morph/src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { morph } from './morph'
1+
import { morph, morphBetween } from './morph'
22

33
export default function (Alpine) {
44
Alpine.morph = morph
5+
Alpine.morphBetween = morphBetween
56
}
67

7-
export { morph }
8+
export { morph, morphBetween }

0 commit comments

Comments
 (0)