// map the rsx name of the element to the html name of the element and the namespace that contains it
pub fn element_to_static_str(element: &str) -> Option<(&'static str, Option<&'static str>)> {
ELEMENTS_WITH_MAPPED_ATTRIBUTES
.iter()
.find(|(el, _)| *el == element)
.map(|(el, _)| (*el, None))
.or_else(|| {
ELEMENTS_WITH_NAMESPACE
.iter()
.find(|(el, _, _)| *el == element)
.map(|(el, ns, _)| (*el, Some(*ns)))
})
.or_else(|| {
ELEMENTS_WITHOUT_NAMESPACE
.iter()
.find(|(el, _)| *el == element)
.map(|(el, _)| (*el, None))
})
}
macro_rules! builder_constructors {
(
$(
$(#[$attr:meta])*
$name:ident {
$(
$(#[$attr_method:meta])*
$fil:ident: $vil:ident,
)*
};
)*
) => {
pub const ELEMENTS_WITHOUT_NAMESPACE: &'static [(&'static str, &'static [&'static str])] = &[
$(
(
stringify!($name),
&[
$(
stringify!($fil),
)*
]
),
)*
];
};
( $(
$(#[$attr:meta])*
$name:ident <> $namespace:tt {
$($fil:ident: $vil:ident,)*
};
)* ) => {
pub const ELEMENTS_WITH_NAMESPACE: &'static [(&'static str, &'static str, &'static [&'static str])] = &[
$(
(
stringify!($name),
stringify!($namespace),
&[
$(
stringify!($fil),
)*
]
),
)*
];
};
}
pub const ELEMENTS_WITH_MAPPED_ATTRIBUTES: &[(&str, &[(&str, &str)])] = &[
("script", &[("r#type", "type"), ("r#script", "script")]),
("button", &[("r#type", "type")]),
("select", &[("value", "value")]),
("option", &[("selected", "selected")]),
("textarea", &[("value", "value")]),
("label", &[("r#for", "for")]),
("input", &[("r#type", "type"), ("value", "value")]),
];
// Organized in the same order as
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
//
// Does not include obsolete elements.
//
// This namespace represents a collection of modern HTML-5 compatiable elements.
//
// This list does not include obsolete, deprecated, experimental, or poorly supported elements.
builder_constructors! {
// Document metadata
/// Build a
/// [`