Improve element building API

This commit is contained in:
Joscha 2024-11-27 17:40:15 +01:00
parent c4b3a279cc
commit a6fd12510d
5 changed files with 154 additions and 92 deletions

View file

@ -2,15 +2,15 @@
//!
//! <https://developer.mozilla.org/en-US/docs/Web/HTML/Element>
use crate::{Element, ElementKind};
use crate::{Element, ElementComponent, ElementKind};
macro_rules! element {
( $name:ident ) => {
element!($name, ElementKind::Normal);
};
( $name:ident, $kind:expr ) => {
pub fn $name() -> Element {
Element::new(stringify!($name), $kind)
pub fn $name(component: impl ElementComponent) -> Element {
Element::new(stringify!($name), $kind).with(component)
}
};
}