Open mrgzi opened 5 months ago
I have some concerns about the binary size impact of typed HTML in WASM. One of the largest pieces of dioxus-web today is just converting a typed enum key in events to and from a string. Each part of typed HTML would need similar logic which may have a large binary size.
For enums, we could actually expand the values to const associated generics with &'static str values which wouldn't have a binary size impact.
In:
input {
r#type: Type::Email,
}
Type
could be a struct like this:
struct Type;
impl Type {
pub const Email: &'static = "email";
}
https://github.com/microsoft/vscode-custom-data has type data vscode uses for autocomplete. We could use it in a build script to generate const associated types for attributes in dioxus. (Could be useful to steal out some of the serde logic from https://github.com/ealmloff/html-parser/blob/main/build.rs)
This would also make autocomplete for values much nicer.
Feature Request
Since Rust is a strongly typed language, it seems sensible to check types in HTML attribute values as well. Currently,
rsx
macro allows the following usage:However, the
maxlength
attribute should actually be an integer:Implement Suggestion
Instead of forcing developers to use strongly typed HTML, we can provide two options:
rsx
macro should validate these strings against the expected data types.Examples;