Skip to content

Lit Light DOM Components Are Removed After hx-swap="morph:outerHTML"ย #3567

@RohiNof

Description

@RohiNof

Hi, Iโ€™m using HTMX with morph in my project. I created a custom Lit component using Light DOM by overriding:

createRenderRoot() {
  return this
}

Problem:
When using:

hx-swap="outerHTML"

everything works fine, and the component keeps its internal DOM structure.

However, when using:

hx-swap="morph:outerHTML"

the internal DOM disappears. Only the custom element tag remains:

Before swap:

<r-api-combobox id="someId" ...>
  <div 
    <wa-input ...>
      ...
    </wa-input>
    <div class="error-message" ...></div>
    <input type="hidden" name="bankId" value="2">
  </div>
</r-api-combobox>

After swap:

<r-api-combobox id="someId" ...></r-api-combobox>

It seems that morph does not preserve the Light DOM children of custom elements, unlike a normal outerHTML swap.

Question:
Is there any configuration or solution to prevent Light DOM children from being removed when using hx-swap="morph:outerHTML" with Lit custom elements?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions