Converting a dom element to virtual-dom in widgets

A widget is almost certainly not the right tool for this.

A widget should not be accessing any other information other than what is fed to it explicitly via args and should then only be concerned about what is going on inside itself and at most send actions back up. It should not be involved in the Dom elsewhere.

You’d be better off using a Component imho.

Is there any reason why you can’t find a javascript function that will process the latex including the maths stuff and return it as html which you can then render in the component? If you can avoid extra-framework dom manipulation completely that would be the best option.