diff --git a/packages/html/src/elements.rs b/packages/html/src/elements.rs
index efbb4d797..aa23d89d4 100644
--- a/packages/html/src/elements.rs
+++ b/packages/html/src/elements.rs
@@ -4,58 +4,124 @@ use crate::{GlobalAttributes, SvgAttributes};
pub type AttributeDiscription = (&'static str, Option<&'static str>, bool);
+macro_rules! impl_attribute {
+ (
+ $(#[$attr_method:meta])*
+ $fil:ident: $vil:ident (DEFAULT),
+ ) => {
+ pub const $fil: AttributeDiscription = (stringify!($fil), None, false);
+ };
+
+ (
+ $(#[$attr_method:meta])*
+ $fil:ident: $vil:ident ($name:literal),
+ ) => {
+ pub const $fil: AttributeDiscription = ($name, None, false);
+ };
+
+ (
+ $(#[$attr_method:meta])*
+ $fil:ident: $vil:ident (volatile),
+ ) => {
+ pub const $fil: AttributeDiscription = (stringify!($fil), None, true);
+ };
+
+ (
+ $(#[$attr_method:meta])*
+ $fil:ident: $vil:ident (in $ns:ident),
+ ) => {
+ pub const $fil: AttributeDiscription = (stringify!($fil), Some(stringify!($ns)), false)
+ };
+
+ (
+ $(#[$attr_method:meta])*
+ $fil:ident: $vil:ident (in $ns:ident : volatile),
+ ) => {
+ pub const $fil: AttributeDiscription = (stringify!($fil), Some(stringify!($ns)), true)
+ };
+}
+
+macro_rules! impl_element {
+ (
+ $(#[$attr:meta])*
+ $name:ident None {
+ $(
+ $(#[$attr_method:meta])*
+ $fil:ident: $vil:ident $extra:tt,
+ )*
+ }
+ ) => {
+ #[allow(non_camel_case_types)]
+ $(#[$attr])*
+ pub struct $name;
+
+
+ impl $name {
+ pub const TAG_NAME: &'static str = stringify!($name);
+ pub const NAME_SPACE: Option<&'static str> = None;
+
+ $(
+ impl_attribute!(
+ $(#[$attr_method])*
+ $fil: $vil ($extra),
+ );
+ )*
+ }
+
+ impl GlobalAttributes for $name {}
+ };
+
+ (
+ $(#[$attr:meta])*
+ $name:ident $namespace:tt {
+ $(
+ $(#[$attr_method:meta])*
+ $fil:ident: $vil:ident $extra:tt,
+ )*
+ }
+ ) => {
+ #[allow(non_camel_case_types)]
+ $(#[$attr])*
+ pub struct $name;
+
+ impl SvgAttributes for $name {}
+
+ impl $name {
+ pub const TAG_NAME: &'static str = stringify!($name);
+ pub const NAME_SPACE: Option<&'static str> = Some($namespace);
+
+ $(
+ impl_attribute!(
+ $(#[$attr_method])*
+ $fil: $vil in $namespace $extra
+ );
+ )*
+ }
+ }
+}
+
macro_rules! builder_constructors {
(
$(
$(#[$attr:meta])*
- $name:ident {
+ $name:ident $namespace:tt {
$(
$(#[$attr_method:meta])*
- $fil:ident: $vil:ident,
+ $fil:ident: $vil:ident $extra:tt,
)*
};
)*
) => {
$(
- #[allow(non_camel_case_types)]
- $(#[$attr])*
- pub struct $name;
-
-
- impl $name {
- pub const TAG_NAME: &'static str = stringify!($name);
- pub const NAME_SPACE: Option<&'static str> = None;
-
- $(
- pub const $fil: AttributeDiscription = (stringify!($fil), None, false);
- )*
- }
-
- impl GlobalAttributes for $name {}
- )*
- };
-
- ( $(
- $(#[$attr:meta])*
- $name:ident <> $namespace:tt {
- $($fil:ident: $vil:ident,)*
- };
- )* ) => {
- $(
- #[allow(non_camel_case_types)]
- $(#[$attr])*
- pub struct $name;
-
- impl SvgAttributes for $name {}
-
- impl $name {
- pub const TAG_NAME: &'static str = stringify!($name);
- pub const NAME_SPACE: Option<&'static str> = Some($namespace);
-
- $(
- pub const $fil: AttributeDiscription = (stringify!($fil), Some(stringify!($namespace)), false)
- )*
- }
+ impl_element!(
+ $(#[$attr])*
+ $name $namespace {
+ $(
+ $(#[$attr_method])*
+ $fil: $vil $extra,
+ )*
+ }
+ );
)*
};
}
@@ -75,63 +141,63 @@ builder_constructors! {
/// [`