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 { macro_rules! trait_methods {
( (
@base @base
$(#[$trait_attr:meta])*
$trait:ident;
$( $(
$(#[$attr:meta])* $(#[$attr:meta])*
$name:ident $(: $($arg:literal),*)*; $name:ident $(: $($arg:literal),*)*;
)+ )+
) => { ) => {
$(#[$trait_attr])*
pub trait $trait {
$( $(
$(#[$attr])* $(#[$attr])*
const $name: AttributeDiscription = trait_methods! { $name $(: $($arg),*)*; }; const $name: AttributeDiscription = trait_methods! { $name $(: $($arg),*)*; };
)* )*
}
}; };
// Rename the incoming ident and apply a custom namespace // Rename the incoming ident and apply a custom namespace
@@ -25,10 +31,12 @@ macro_rules! trait_methods {
// Don't rename the incoming ident // Don't rename the incoming ident
( $name:ident; ) => { (stringify!($name), None, false) }; ( $name:ident; ) => { (stringify!($name), None, false) };
} }
pub trait GlobalAttributes {
trait_methods! { trait_methods! {
@base @base
GlobalAttributes;
/// Prevent the default action for this element. /// Prevent the default action for this element.
/// ///
/// For more information, see the MDN docs: /// 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> /// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-roledescription>
aria_roledescription: "aria-roledescription"; aria_roledescription: "aria-roledescription";
// Widget Attributes // Widget Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-autocomplete> /// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-autocomplete>
aria_autocomplete: "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> /// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-valuetext>
aria_valuetext: "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> /// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-atomic>
aria_atomic: "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> /// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-grabbed>
aria_grabbed: "aria-grabbed"; aria_grabbed: "aria-grabbed";
// Relationship Attributes // Relationship Attributes
/// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-activedescendant> /// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-activedescendant>
aria_activedescendant: "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> /// <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-setsize>
aria_setsize: "aria-setsize"; aria_setsize: "aria-setsize";
}
} }
pub trait SvgAttributes { trait_methods! {
trait_methods! {
@base @base
SvgAttributes;
/// Prevent the default action for this element. /// Prevent the default action for this element.
/// ///
/// For more information, see the MDN docs: /// 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> /// <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/zoomAndPan>
zoomAndPan: "zoomAndPan"; zoomAndPan: "zoomAndPan";
}
} }