mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
Merge pull request #1664 from ealmloff/fix-svg-hot-reload
Fix hot reloading svg elements
This commit is contained in:
commit
ecb1b61b65
2 changed files with 50 additions and 5 deletions
|
@ -122,7 +122,7 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
|
||||||
} = cfg;
|
} = cfg;
|
||||||
|
|
||||||
if let Ok(crate_dir) = PathBuf::from_str(root_path) {
|
if let Ok(crate_dir) = PathBuf::from_str(root_path) {
|
||||||
// try to find the gitingore file
|
// try to find the gitignore file
|
||||||
let gitignore_file_path = crate_dir.join(".gitignore");
|
let gitignore_file_path = crate_dir.join(".gitignore");
|
||||||
let (gitignore, _) = ignore::gitignore::Gitignore::new(gitignore_file_path);
|
let (gitignore, _) = ignore::gitignore::Gitignore::new(gitignore_file_path);
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ macro_rules! impl_attribute_match {
|
||||||
$attr:ident $fil:ident: $vil:ident (in $ns:literal),
|
$attr:ident $fil:ident: $vil:ident (in $ns:literal),
|
||||||
) => {
|
) => {
|
||||||
if $attr == stringify!($fil) {
|
if $attr == stringify!($fil) {
|
||||||
return Some((stringify!(fil), Some(ns)));
|
return Some((stringify!(fil), Some($ns)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -180,14 +180,26 @@ macro_rules! impl_element_match {
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
$el:ident $name:ident $namespace:tt {
|
$el:ident $name:ident $namespace:literal {
|
||||||
$(
|
$(
|
||||||
$fil:ident: $vil:ident $extra:tt,
|
$fil:ident: $vil:ident $extra:tt,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
if $el == stringify!($name) {
|
if $el == stringify!($name) {
|
||||||
return Some((stringify!($name), Some(stringify!($namespace))));
|
return Some((stringify!($name), Some($namespace)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(
|
||||||
|
$el:ident $name:ident [$_:literal, $namespace:tt] {
|
||||||
|
$(
|
||||||
|
$fil:ident: $vil:ident $extra:tt,
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
if $el == stringify!($name) {
|
||||||
|
return Some((stringify!($name), Some($namespace)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -207,6 +219,8 @@ macro_rules! impl_element_match_attributes {
|
||||||
$attr $fil: $vil ($extra),
|
$attr $fil: $vil ($extra),
|
||||||
);
|
);
|
||||||
)*
|
)*
|
||||||
|
|
||||||
|
return impl_map_global_attributes!($el $attr $name None);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -223,10 +237,41 @@ macro_rules! impl_element_match_attributes {
|
||||||
$attr $fil: $vil ($extra),
|
$attr $fil: $vil ($extra),
|
||||||
);
|
);
|
||||||
)*
|
)*
|
||||||
|
|
||||||
|
return impl_map_global_attributes!($el $attr $name $namespace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "hot-reload-context")]
|
||||||
|
macro_rules! impl_map_global_attributes {
|
||||||
|
(
|
||||||
|
$el:ident $attr:ident $element:ident None
|
||||||
|
) => {
|
||||||
|
map_global_attributes($attr)
|
||||||
|
};
|
||||||
|
|
||||||
|
(
|
||||||
|
$el:ident $attr:ident $element:ident $namespace:literal
|
||||||
|
) => {
|
||||||
|
if $namespace == "http://www.w3.org/2000/svg" {
|
||||||
|
map_svg_attributes($attr)
|
||||||
|
} else {
|
||||||
|
map_global_attributes($attr)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(
|
||||||
|
$el:ident $attr:ident $element:ident [$name:literal, $namespace:tt]
|
||||||
|
) => {
|
||||||
|
if $namespace == "http://www.w3.org/2000/svg" {
|
||||||
|
map_svg_attributes($attr)
|
||||||
|
} else {
|
||||||
|
map_global_attributes($attr)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! builder_constructors {
|
macro_rules! builder_constructors {
|
||||||
(
|
(
|
||||||
$(
|
$(
|
||||||
|
@ -254,7 +299,7 @@ macro_rules! builder_constructors {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
)*
|
)*
|
||||||
map_global_attributes(attribute).or_else(|| map_svg_attributes(attribute))
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_element(element: &str) -> Option<(&'static str, Option<&'static str>)> {
|
fn map_element(element: &str) -> Option<(&'static str, Option<&'static str>)> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue