# Converting a dom element to virtual-dom in widgets

**URL:** <https://meta.discourse.org/t/converting-a-dom-element-to-virtual-dom-in-widgets/238346>\
**Category:** Development\
**Created:** [September 7, 2022, 2:28pm UTC](https://meta.discourse.org/t/converting-a-dom-element-to-virtual-dom-in-widgets/238346 "2022-09-07T14:28:55Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![attj](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@attj](https://meta.discourse.org/u/attj)\
**Post date:** [September 7, 2022, 2:28pm UTC](https://meta.discourse.org/t/converting-a-dom-element-to-virtual-dom-in-widgets/238346/1 "2022-09-07T14:28:56Z")

</div>

I currently have a dom element that is a result of a custom katex render.

It is generated like this:

```plaintext
var dom_element = document.createElement("p")
dom_element.innerHTML = "some text that contain latex"
renderMathInElement(dom_element)

```

At this point dom\_element contains the html that I would like to render. And I return it like this:

```plaintext
html() {
 return h(some other component ...... , h("div", dom_element))
}

```

Since h expects a VNode, this gives an error. I try to give the inner html instead:

```plaintext
html() {
 return h(some other component ...... , h("div", dom_element.innerHTML))
}

```

This renders the tags inside dom\_element.innerHTML as pure text and not as html.

Is there a solution to this?

---

_[View the full topic](https://meta.discourse.org/t/converting-a-dom-element-to-virtual-dom-in-widgets/238346)._
