Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/docs/src/en/plugins/morph.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,15 @@ By adding keys to each node, we can accomplish this like so:
Now that there are "keys" on the `<li>`s, Morph will match them in both trees and move them accordingly.

You can configure what Morph considers a "key" with the `key:` configuration option. [More on that here](#lifecycle-hooks)

<a name="alpine-morph-between"></a>
## Alpine.morphBetween()

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.

| Parameter | Description |
| --- | --- |
| `startMarker` | A DOM node (typically a comment node) that marks the beginning of the range to morph |
| `endMarker` | A DOM node (typically a comment node) that marks the end of the range to morph |
| `newHtml` | A string of HTML or a DOM element to replace the content between the markers |
| `options` | An object of options (same as `Alpine.morph()`) |
5 changes: 3 additions & 2 deletions packages/morph/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { morph } from './morph'
import { morph, morphBetween } from './morph'

export default function (Alpine) {
Alpine.morph = morph
Alpine.morphBetween = morphBetween
}

export { morph }
export { morph, morphBetween }
Loading