engremran07/gsmvault/alp-morph-dom-diff

Claude Code and agent skill by engremran07/gsmvault

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

DOM diffing with Alpine morph. Use when: updating DOM efficiently from server HTML, HTMX swap alternatives, preserving Alpine state during DOM updates.

Install

npx vskill@latest install engremran07/gsmvault/alp-morph-dom-diff

SKILL.md

The same SKILL.md was published earlier as engremran07/gsmvault/alp-morph-dom-diff.

Alpine Morph — DOM Diffing

When to Use

  • Updating a section of the page from server HTML without losing Alpine state
  • HTMX morph swap strategy for seamless partial updates
  • Re-rendering component HTML while keeping reactive state intact

Patterns

Alpine.morph for Manual DOM Update
html
<script>
async function refreshSection(el) {
const res = await fetch(el.dataset.url);
const html = await res.text();
const template = document.createElement('template');
template.innerHTML = html.trim();
Alpine.morph(el, template.content.firstElementChild);
}
</script>
<div x-data="{ count: 0 }" data-url="/fragments/stats/"
@refresh-stats.window="refreshSection($el)">
<p>Count: <span x-text="count"></span></p>
<!-- Server HTML updates structure, but Alpine state (count) persists -->
</div>
HTMX with Morph Swap

Configure HTMX to use morph swap for Alpine-compatible updates:

html
<div hx-get="/firmwares/fragments/list/"
hx-trigger="filter-changed from:body"
hx-swap="morph:innerHTML"
hx-target="this">
{% for fw in firmwares %}
<div x-data="{ expanded: false }">
<button @click="expanded = !expanded" x-text="'{{ fw.name|escapejs }}'"></button>
<div x-show="expanded" x-cloak x-transition>Details...</div>
</div>
{% endfor %}
</div>
Morph with Key Preservation

Use id attributes to help morph identify matching elements:

html
<ul id="notification-list">
<template x-for="n in $store.notifications.items" :key="n.id">
<li :id="'notif-' + n.id" :class="{ 'font-bold': !n.read }">
<span x-text="n.message"></span>
</li>
</template>
</ul>

Anti-Patterns

PatternProblemFix
innerHTML = to replace Alpine-managed DOMDestroys reactive stateUse Alpine.morph()
Morph without stable id attributesMorph can't match elements, causes flickerAdd id to key elements
Using morph for tiny updatesOverkill, worse perf than targeted updateUse reactive x-text/x-bind for simple changes

Red Flags

  • el.innerHTML = html inside an Alpine component — destroys state
  • HTMX hx-swap="innerHTML" on Alpine-reactive elements — should use morph
  • Alpine.morph called on elements without stable identifiers

Quality Gate

powershell
& .\.venv\Scripts\python.exe -m ruff check . --fix
& .\.venv\Scripts\python.exe -m ruff format .
& .\.venv\Scripts\python.exe manage.py check --settings=app.settings_dev

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/engremran07/gsmvault/alp-morph-dom-diff/badge)](https://verified-skill.com/skills/engremran07/gsmvault/alp-morph-dom-diff)

Something wrong with this skill or its page? Tell us.