bigskysoftware / bigskysoftware/htmx

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

Open
#3,567 8 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

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:

```


...



```

After swap:
```

```
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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.