bigskysoftware / idiomorph

A DOM-merging algorithm
BSD 2-Clause "Simplified" License
693 stars 33 forks source link

Bug Report: `hx-swap` "morph:outerHTML" Doesn't Recognize New `hx-trigger` Attributes #14

Closed HenryMorgan-cd2 closed 9 months ago

HenryMorgan-cd2 commented 1 year ago

Description:

When using the idiomorph-ext extension with htmx, setting hx-swap to "morph:outerHTML" doesn't properly recognize and apply new hx-trigger attributes from the fetched content.

Reproduction:

LIVE EXAMPLE: https://clever-clam-66.deno.dev/ GITHUB: https://github.com/HenryMorgan-cd2/htmx-idiomorph-swap-bug

<!-- /content -->
<div
  hx-get="/content"
  hx-swap="outerHTML"
  hx-trigger="load delay:1s"
>
  DATE: ${new Date()}
</div>
  1. HTML Markup (showcasing the issue):
    <div hx-ext="morph">
    <div
    hx-get="/content"
    hx-swap="morph:outerHTML"
    hx-trigger="load 1s"
    >
    ORIGINAL CONTENT
    </div>
    </div>

Expected Behavior:

On swapping, the newly fetched content's hx-trigger attribute should be respected and its behavior should be applied. Causing this component to load poll.

Actual Behavior:

The hx-trigger is not applied to the newly fetched content so the content does not poll.

Additional Information:

If the original element has a hx-trigger of "every 1s", then that trigger will still be active post-swap.

1cg commented 9 months ago

This should be fixed in the latest version of idiomorph (v0.2.0)