chore: adjust attribute macro

This commit is contained in:
Jonathan Kelley 2022-12-23 19:46:09 -05:00
parent a0b0558624
commit 2409d499e0

View file

@ -5,15 +5,21 @@ use crate::AttributeDiscription;
macro_rules! trait_methods {
(
@base
$(#[$trait_attr:meta])*
$trait:ident;
$(
$(#[$attr:meta])*
$name:ident $(: $($arg:literal),*)*;
)+
) => {
$(#[$trait_attr])*
pub trait $trait {
$(
$(#[$attr])*
const $name: AttributeDiscription = trait_methods! { $name $(: $($arg),*)*; };
)*
}
};
// Rename the incoming ident and apply a custom namespace
@ -25,10 +31,12 @@ macro_rules! trait_methods {
// Don't rename the incoming ident
( $name:ident; ) => { (stringify!($name), None, false) };
}
pub trait GlobalAttributes {
trait_methods! {
@base
GlobalAttributes;
/// Prevent the default action for this element.
///
/// For more information, see the MDN docs:
@ -1534,12 +1542,12 @@ pub trait GlobalAttributes {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-setsize>
aria_setsize: "aria-setsize";
}
}
pub trait SvgAttributes {
trait_methods! {
@base
SvgAttributes;
/// Prevent the default action for this element.
///
/// For more information, see the MDN docs:
@ -2293,5 +2301,5 @@ pub trait SvgAttributes {
/// <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/zoomAndPan>
zoomAndPan: "zoomAndPan";
}
}