Skip to content

[0.7] view! is unhygienic #3161

@jaskij

Description

@jaskij

Describe the bug

Using 0.7.0-rc0, the view! macro does not compile if leptos::prelude::ElementChild is not in scope.

Leptos Dependencies

leptos = { version = "0.7.0-rc0", default-features = false, features = ["csr"] }

To Reproduce

The code below will not compile without use leptos::prelude::ElementChild on line 3. Adding #[component] does not change the result, so I have removed it to minimize the code.

use leptos::{view, prelude::ClassAttribute, IntoView};
// this is not referenced directly anywhere
use leptos::prelude::ElementChild;

#[allow(non_snake_case)]
pub fn BadView(title: String, body: String) -> impl IntoView {
    view! {
        <div class="content"><hgroup>
            <h1>{title}</h1>
        </hgroup></div>
        <div class="content">{body}</div>
    }
}

Expected behavior
The code should compile.

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions