make html hot reloding context work
This commit is contained in:
1 parent
6d2e510200
commit
ab743e01b7
1 file changed
+60
-67
@@ -43,24 +43,35 @@ macro_rules! impl_attribute {
|
|||||||
|
|
||||||
macro_rules! impl_attribute_match {
|
macro_rules! impl_attribute_match {
|
||||||
(
|
(
|
||||||
$(#[$attr_method:meta])*
|
$attr:ident $fil:ident: $vil:ident (DEFAULT),
|
||||||
$fil:ident: $vil:ident (DEFAULT),
|
|
||||||
) => {
|
) => {
|
||||||
stringify!($fil) => Some((stringify!($fil), None))
|
if $attr == stringify!($fil) {
|
||||||
|
return Some((stringify!($fil), None));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
$(#[$attr_method:meta])*
|
$attr:ident $fil:ident: $vil:ident (volatile),
|
||||||
$fil:ident: $vil:ident ($name:literal),
|
|
||||||
) => {
|
) => {
|
||||||
stringify!($fil) => Some(($name, None))
|
if $attr == stringify!($fil) {
|
||||||
|
return Some((stringify!($fil), None));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
$(#[$attr_method:meta])*
|
$attr:ident $fil:ident: $vil:ident ($name:literal),
|
||||||
$fil:ident: $vil:ident (in $ns:ident),
|
|
||||||
) => {
|
) => {
|
||||||
stringify!($fil) => Some((stringify!(fil), Some(stringify!(ns))))
|
if $attr == stringify!($fil) {
|
||||||
|
return Some(($name, None));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(
|
||||||
|
$attr:ident $fil:ident: $vil:ident (in $ns:ident),
|
||||||
|
) => {
|
||||||
|
if $attr == stringify!($fil) {
|
||||||
|
return Some((stringify!(fil), Some(stringify!(ns))));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,29 +135,25 @@ macro_rules! impl_element {
|
|||||||
|
|
||||||
macro_rules! impl_element_match {
|
macro_rules! impl_element_match {
|
||||||
(
|
(
|
||||||
$(#[$attr:meta])*
|
$el:ident $name:ident None {
|
||||||
$name:ident None {
|
|
||||||
$(
|
$(
|
||||||
$(#[$attr_method:meta])*
|
|
||||||
$fil:ident: $vil:ident $extra:tt,
|
$fil:ident: $vil:ident $extra:tt,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
if element == stringify!($name) {
|
if $el == stringify!($name) {
|
||||||
return Some((stringify!($name), None));
|
return Some((stringify!($name), None));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
$(#[$attr:meta])*
|
$el:ident $name:ident $namespace:tt {
|
||||||
$name:ident $namespace:ident {
|
|
||||||
$(
|
$(
|
||||||
$(#[$attr_method:meta])*
|
|
||||||
$fil:ident: $vil:ident $extra:tt,
|
$fil:ident: $vil:ident $extra:tt,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
if element == stringify!($name) {
|
if $el == stringify!($name) {
|
||||||
return Some((stringify!($name), Some(stringify!($namespace))));
|
return Some((stringify!($name), Some(stringify!($namespace))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -154,42 +161,34 @@ macro_rules! impl_element_match {
|
|||||||
|
|
||||||
macro_rules! impl_element_match_attributes {
|
macro_rules! impl_element_match_attributes {
|
||||||
(
|
(
|
||||||
$(#[$attr:meta])*
|
$el:ident $attr:ident $name:ident None {
|
||||||
$name:ident None {
|
|
||||||
$(
|
$(
|
||||||
$(#[$attr_method:meta])*
|
|
||||||
$fil:ident: $vil:ident $extra:tt,
|
$fil:ident: $vil:ident $extra:tt,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
stringify!($name) => match attr{
|
if $el == stringify!($name) {
|
||||||
$(
|
$(
|
||||||
impl_attribute_match!(
|
impl_attribute_match!(
|
||||||
$(#[$attr_method])*
|
$attr $fil: $vil ($extra),
|
||||||
$fil: $vil ($extra),
|
);
|
||||||
),
|
|
||||||
)*
|
)*
|
||||||
_ => None,
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
$(#[$attr:meta])*
|
$el:ident $attr:ident $name:ident $namespace:tt {
|
||||||
$name:ident $namespace:tt {
|
|
||||||
$(
|
$(
|
||||||
$(#[$attr_method:meta])*
|
|
||||||
$fil:ident: $vil:ident $extra:tt,
|
$fil:ident: $vil:ident $extra:tt,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
stringify!($name) => match attr{
|
if $el == stringify!($name) {
|
||||||
$(
|
$(
|
||||||
impl_attribute_match!(
|
impl_attribute_match!(
|
||||||
$(#[$attr_method])*
|
$attr $fil: $vil in $namespace $extra
|
||||||
$fil: $vil in $namespace $extra
|
);
|
||||||
),
|
|
||||||
)*
|
)*
|
||||||
_ => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,50 +208,44 @@ macro_rules! builder_constructors {
|
|||||||
pub struct Html;
|
pub struct Html;
|
||||||
|
|
||||||
impl HotReloadingContext for Html {
|
impl HotReloadingContext for Html {
|
||||||
fn map_attribute(element: &str, attr: &str) -> Option<(&'static str, Option<&'static str>)> {
|
fn map_attribute(element: &str, attribute: &str) -> Option<(&'static str, Option<&'static str>)> {
|
||||||
match element {
|
|
||||||
// $(
|
|
||||||
// impl_element_match_attributes!(
|
|
||||||
// $(#[$attr])*
|
|
||||||
// $name $namespace {
|
|
||||||
// $(
|
|
||||||
// $(#[$attr_method])*
|
|
||||||
// $fil: $vil $extra,
|
|
||||||
// )*
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// )*
|
|
||||||
_ => None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn map_element(element: &str) -> Option<(&'static str, Option<&'static str>)> {
|
|
||||||
$(
|
$(
|
||||||
impl_element_match!(
|
impl_element_match_attributes!(
|
||||||
$(#[$attr])*
|
element attribute $name $namespace {
|
||||||
$name $namespace {
|
|
||||||
$(
|
$(
|
||||||
$(#[$attr_method])*
|
|
||||||
$fil: $vil $extra,
|
$fil: $vil $extra,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
)*
|
)*
|
||||||
unreachable!()
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn map_element(element: &str) -> Option<(&'static str, Option<&'static str>)> {
|
||||||
|
$(
|
||||||
|
impl_element_match!(
|
||||||
|
element $name $namespace {
|
||||||
|
$(
|
||||||
|
$fil: $vil $extra,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
);
|
||||||
|
)*
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $(
|
$(
|
||||||
// impl_element!(
|
impl_element!(
|
||||||
// $(#[$attr])*
|
$(#[$attr])*
|
||||||
// $name $namespace {
|
$name $namespace {
|
||||||
// $(
|
$(
|
||||||
// $(#[$attr_method])*
|
$(#[$attr_method])*
|
||||||
// $fil: $vil $extra,
|
$fil: $vil $extra,
|
||||||
// )*
|
)*
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
// )*
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user