Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xilem_web: Possible bug when using .boxed and changing type of HTML node #465

Closed
casey opened this issue Jul 29, 2024 · 2 comments · Fixed by #468
Closed

xilem_web: Possible bug when using .boxed and changing type of HTML node #465

casey opened this issue Jul 29, 2024 · 2 comments · Fixed by #468

Comments

@casey
Copy link
Contributor

casey commented Jul 29, 2024

I think I found an issue when using .boxed combinator from #460 and using it to dynamically change the type of HTML element.

I created a minimal reproduction here, which looks like this:

use xilem_web::{document_body, elements::html, interfaces::Element, App, DomView};

fn update(state: &mut bool) -> impl DomView<bool> {
    html::div((
        html::button("click me!").on_click(|state: &mut bool, _| *state = !*state),
        html::br(()),
        if *state {
            html::div("div!").boxed()
        } else {
            html::span("span!").boxed()
        },
    ))
}

fn main() {
    App::new(document_body(), false, update).run();
}

The boxed element keeps it's initial type and text, even when the button is clicked. If the state is false initially, it stays a <span>, and if true a <div>.

Philipp-M added a commit to Philipp-M/xilem that referenced this issue Jul 29, 2024
Philipp-M added a commit to Philipp-M/xilem that referenced this issue Jul 29, 2024
@Philipp-M
Copy link
Contributor

Thanks for the repro, that made fixing this easy, internally the element was changed, but the actual DOM node in the tree wasn't.

@casey
Copy link
Contributor Author

casey commented Jul 29, 2024

Nice! Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants