chore: adjust attribute macro

This commit is contained in:
Jonathan Kelley committed 2022-12-23 19:46:09 -05:00
1 parent a0b0558624
commit 2409d499e0
1 file changed
+17 -9
+17 -9
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! {
trait_methods! {
@base
GlobalAttributes;
/// Prevent the default action for this element.
///
/// For more information, see the MDN docs:
@@ -1408,7 +1416,7 @@ pub trait GlobalAttributes {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-roledescription>
aria_roledescription: "aria-roledescription";
// Widget Attributes
// Widget Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-autocomplete>
aria_autocomplete: "aria-autocomplete";
@@ -1467,7 +1475,7 @@ pub trait GlobalAttributes {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-valuetext>
aria_valuetext: "aria-valuetext";
// Live Region Attributes
// Live Region Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-atomic>
aria_atomic: "aria-atomic";
@@ -1487,7 +1495,7 @@ pub trait GlobalAttributes {
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-grabbed>
aria_grabbed: "aria-grabbed";
// Relationship Attributes
// Relationship Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-activedescendant>
aria_activedescendant: "aria-activedescendant";
@@ -1533,13 +1541,13 @@ 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! {
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";
}
}