// 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), $namespace, &[ $( stringify!($fil), )* ] ), )* ]; }; } type MappedAttributes = &'static [(&'static str, &'static [(&'static str, &'static str, bool)])]; /// All attributes that are tied to a specific element that either have a different name, or are volitile pub const ELEMENTS_WITH_MAPPED_ATTRIBUTES: MappedAttributes = &[ ( "script", &[("r#type", "type", false), ("r#script", "script", false)], ), ("button", &[("r#type", "type", false)]), ("select", &[("value", "value", true)]), ("option", &[("selected", "selected", true)]), ("textarea", &[("value", "value", true)]), ("label", &[("r#for", "for", false)]), ( "input", &[("r#type", "type", false), ("value", "value", true)], ), ]; // 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 /// [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) /// element. /// base { href: Uri, target: Target, }; /// Build a /// [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head) /// element. head {}; /// Build a /// [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) /// element. link { // as: Mime, crossorigin: CrossOrigin, href: Uri, hreflang: LanguageTag, media: String, // FIXME media query rel: LinkType, sizes: String, // FIXME title: String, // FIXME r#type: Mime, integrity: String, }; /// Build a /// [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) /// element. meta { charset: String, // FIXME IANA standard names content: String, http_equiv: HTTPEquiv, name: Metadata, }; /// Build a /// [`