Merge branch 'master' into jk/global-window-fun
This commit is contained in:
200 files changed
+6082
-2375
No files matched your search
@@ -74,7 +74,26 @@ macro_rules! impl_attribute_match {
|
||||
$attr:ident $fil:ident: $vil:ident (in $ns:literal),
|
||||
) => {
|
||||
if $attr == stringify!($fil) {
|
||||
return Some((stringify!(fil), Some(ns)));
|
||||
return Some((stringify!(fil), Some($ns)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "html-to-rsx")]
|
||||
macro_rules! impl_html_to_rsx_attribute_match {
|
||||
(
|
||||
$attr:ident $fil:ident $name:literal
|
||||
) => {
|
||||
if $attr == $name {
|
||||
return Some(stringify!($fil));
|
||||
}
|
||||
};
|
||||
|
||||
(
|
||||
$attr:ident $fil:ident $_:tt
|
||||
) => {
|
||||
if $attr == stringify!($fil) {
|
||||
return Some(stringify!($fil));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -180,14 +199,26 @@ macro_rules! impl_element_match {
|
||||
};
|
||||
|
||||
(
|
||||
$el:ident $name:ident $namespace:tt {
|
||||
$el:ident $name:ident $namespace:literal {
|
||||
$(
|
||||
$fil:ident: $vil:ident $extra:tt,
|
||||
)*
|
||||
}
|
||||
) => {
|
||||
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 +238,8 @@ macro_rules! impl_element_match_attributes {
|
||||
$attr $fil: $vil ($extra),
|
||||
);
|
||||
)*
|
||||
|
||||
return impl_map_global_attributes!($el $attr $name None);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -223,10 +256,41 @@ macro_rules! impl_element_match_attributes {
|
||||
$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 {
|
||||
(
|
||||
$(
|
||||
@@ -254,7 +318,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>)> {
|
||||
@@ -271,6 +335,38 @@ macro_rules! builder_constructors {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "html-to-rsx")]
|
||||
pub fn map_html_attribute_to_rsx(html: &str) -> Option<&'static str> {
|
||||
$(
|
||||
$(
|
||||
impl_html_to_rsx_attribute_match!(
|
||||
html $fil $extra
|
||||
);
|
||||
)*
|
||||
)*
|
||||
|
||||
if let Some(name) = crate::map_html_global_attributes_to_rsx(html) {
|
||||
return Some(name);
|
||||
}
|
||||
|
||||
if let Some(name) = crate::map_html_svg_attributes_to_rsx(html) {
|
||||
return Some(name);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "html-to-rsx")]
|
||||
pub fn map_html_element_to_rsx(html: &str) -> Option<&'static str> {
|
||||
$(
|
||||
if html == stringify!($name) {
|
||||
return Some(stringify!($name));
|
||||
}
|
||||
)*
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
$(
|
||||
impl_element!(
|
||||
$(#[$attr])*
|
||||
@@ -782,6 +878,7 @@ builder_constructors! {
|
||||
decoding: ImageDecoding DEFAULT,
|
||||
height: usize DEFAULT,
|
||||
ismap: Bool DEFAULT,
|
||||
loading: String DEFAULT,
|
||||
src: Uri DEFAULT,
|
||||
srcset: String DEFAULT, // FIXME this is much more complicated
|
||||
usemap: String DEFAULT, // FIXME should be a fragment starting with '#'
|
||||
@@ -952,9 +1049,8 @@ builder_constructors! {
|
||||
src: Uri DEFAULT,
|
||||
text: String DEFAULT,
|
||||
|
||||
// r#async: Bool,
|
||||
// r#type: String, // TODO could be an enum
|
||||
r#type: String "type",
|
||||
r#async: Bool "async",
|
||||
r#type: String "type", // TODO could be an enum
|
||||
r#script: String "script",
|
||||
};
|
||||
|
||||
|
||||
@@ -119,10 +119,7 @@ impl_event! {
|
||||
/// oncontextmenu
|
||||
oncontextmenu
|
||||
|
||||
/// ondoubleclick
|
||||
ondoubleclick
|
||||
|
||||
/// ondoubleclick
|
||||
#[deprecated(since = "0.5.0", note = "use ondoubleclick instead")]
|
||||
ondblclick
|
||||
|
||||
/// onmousedown
|
||||
@@ -149,6 +146,22 @@ impl_event! {
|
||||
onmouseup
|
||||
}
|
||||
|
||||
/// ondoubleclick
|
||||
#[inline]
|
||||
pub fn ondoubleclick<'a, E: crate::EventReturn<T>, T>(
|
||||
_cx: &'a ::dioxus_core::ScopeState,
|
||||
mut _f: impl FnMut(::dioxus_core::Event<MouseData>) -> E + 'a,
|
||||
) -> ::dioxus_core::Attribute<'a> {
|
||||
::dioxus_core::Attribute::new(
|
||||
"ondblclick",
|
||||
_cx.listener(move |e: ::dioxus_core::Event<MouseData>| {
|
||||
_f(e).spawn(_cx);
|
||||
}),
|
||||
None,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
impl MouseData {
|
||||
/// Construct MouseData with the specified properties
|
||||
///
|
||||
|
||||
@@ -33,12 +33,44 @@ macro_rules! trait_method_mapping {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "html-to-rsx")]
|
||||
macro_rules! html_to_rsx_attribute_mapping {
|
||||
(
|
||||
$matching:ident;
|
||||
$(#[$attr:meta])*
|
||||
$name:ident;
|
||||
) => {
|
||||
if $matching == stringify!($name) {
|
||||
return Some(stringify!($name));
|
||||
}
|
||||
};
|
||||
(
|
||||
$matching:ident;
|
||||
$(#[$attr:meta])*
|
||||
$name:ident: $lit:literal;
|
||||
) => {
|
||||
if $matching == stringify!($lit) {
|
||||
return Some(stringify!($name));
|
||||
}
|
||||
};
|
||||
(
|
||||
$matching:ident;
|
||||
$(#[$attr:meta])*
|
||||
$name:ident: $lit:literal, $ns:literal;
|
||||
) => {
|
||||
if $matching == stringify!($lit) {
|
||||
return Some(stringify!($name));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! trait_methods {
|
||||
(
|
||||
@base
|
||||
$(#[$trait_attr:meta])*
|
||||
$trait:ident;
|
||||
$fn:ident;
|
||||
$fn_html_to_rsx:ident;
|
||||
$(
|
||||
$(#[$attr:meta])*
|
||||
$name:ident $(: $($arg:literal),*)*;
|
||||
@@ -62,6 +94,18 @@ macro_rules! trait_methods {
|
||||
)*
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "html-to-rsx")]
|
||||
#[doc = "Converts an HTML attribute to an RSX attribute"]
|
||||
pub(crate) fn $fn_html_to_rsx(html: &str) -> Option<&'static str> {
|
||||
$(
|
||||
html_to_rsx_attribute_mapping! {
|
||||
html;
|
||||
$name$(: $($arg),*)*;
|
||||
}
|
||||
)*
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
// Rename the incoming ident and apply a custom namespace
|
||||
@@ -79,6 +123,7 @@ trait_methods! {
|
||||
|
||||
GlobalAttributes;
|
||||
map_global_attributes;
|
||||
map_html_global_attributes_to_rsx;
|
||||
|
||||
/// Prevent the default action for this element.
|
||||
///
|
||||
@@ -269,6 +314,9 @@ trait_methods! {
|
||||
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/azimuth>
|
||||
azimuth: "azimuth", "style";
|
||||
|
||||
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter>
|
||||
backdrop_filter: "backdrop-filter", "style";
|
||||
|
||||
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/backface-visibility>
|
||||
backface_visibility: "backface-visibility", "style";
|
||||
|
||||
@@ -1590,6 +1638,7 @@ trait_methods! {
|
||||
@base
|
||||
SvgAttributes;
|
||||
map_svg_attributes;
|
||||
map_html_svg_attributes_to_rsx;
|
||||
|
||||
/// Prevent the default action for this element.
|
||||
///
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
mod elements;
|
||||
#[cfg(feature = "hot-reload-context")]
|
||||
pub use elements::HtmlCtx;
|
||||
#[cfg(feature = "html-to-rsx")]
|
||||
pub use elements::{map_html_attribute_to_rsx, map_html_element_to_rsx};
|
||||
pub mod events;
|
||||
pub mod geometry;
|
||||
mod global_attributes;
|
||||
|
||||
Reference in new issue
Block a user