DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
20.32k stars 779 forks source link

`dangerous_inner_html` does not render properly in SSR #941

Closed alice-werefox closed 1 year ago

alice-werefox commented 1 year ago

Problem

When attempting to pre-render using dioxus_ssr, having a dangerous_inner_html attribute does not render properly.

Steps To Reproduce

Steps to reproduce the behavior:

Expected behavior

What should happen, I suspect, is that the rendered element's dangerous_inner_html attribute should be rendered the same as it would if I ran dioxus serve and loaded the page.

What does end up happening is that instead I get a div with the attribute and the raw HTML as text assigned to that attribute.

Environment:

Questionnaire

Note For my own case, since I'm using Rocket as the backend and am shoving the pre-rendered HTML into a template render that allows escaping HTML, this works just fine. The only change I've had to make is conditional compilation based on whether I'm compiling for target_family = wasm. That way if I'm using Rocket, it will function as it does now and work just fine, and if I'm using dioxus serve it'll conditionally compile a variant that renders it using the dangerous_inner_html attribute.

jkelleyrtp commented 1 year ago

Good catch, that's definitely a bug!