yewstack / yew

Rust / Wasm framework for creating reliable and efficient web applications

Home Page:https://yew.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Text nodes in root of Html::from_html_unchecked string are skipped

ColonelThirtyTwo opened this issue · comments

Problem

When creating a node with Html::from_html_unchecked, text that is not wrapped in another tag (ie at the root level) is not inserted into the DOM - it is not on the page nor in the inspector.

Steps To Reproduce

use yew::prelude::*;

#[function_component(App)]
pub fn app() -> Html {

    let content = Html::from_html_unchecked("hello<br/>world!".into());

    html! {
        <main>
            {content}
        </main>
    }
}

fn main() {
    yew::Renderer::<App>::new().render();
}

Expected behavior

The page says "Hello world!" on two lines.

Instead, neither of the text nodes are in the document, but the <br/> element is. Wrapping the HTML in a div makes it appear.

Screenshots
N/A

Environment:

  • Yew version: 0.20
  • Rust version: 1.70.0
  • Target, if relevant: wasm32-unknown-unknown
  • Build tool, if relevant: not relevant
  • OS, if relevant: not relevant
  • Browser and version, if relevant: Firefox

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later

I believe the underlying issue has been fixed in #3048 as a side effect a while ago. Can you perhaps target the master branch of yew and see if that avoids the issue?

Yeah, it works on master. Guess I'll wait for the release then.