Fix: expose AttributeValue; update tests to pass
This commit is contained in:
1 parent
2eca71e644
commit
85aa4584ff
3 files changed
+13
-6
No files matched your search
@@ -1,9 +1,11 @@
|
|||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
|
|
||||||
|
/// Possible values for an attribute
|
||||||
// trying to keep values at 3 bytes
|
// trying to keep values at 3 bytes
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum AttributeValue<'a> {
|
pub enum AttributeValue<'a> {
|
||||||
Text(&'a str),
|
Text(&'a str),
|
||||||
Float32(f32),
|
Float32(f32),
|
||||||
@@ -26,6 +28,8 @@ pub enum AttributeValue<'a> {
|
|||||||
Any(ArbitraryAttributeValue<'a>),
|
Any(ArbitraryAttributeValue<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo
|
||||||
|
#[allow(missing_docs)]
|
||||||
impl<'a> AttributeValue<'a> {
|
impl<'a> AttributeValue<'a> {
|
||||||
pub fn is_truthy(&self) -> bool {
|
pub fn is_truthy(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
@@ -113,6 +117,8 @@ impl<'de, 'a> serde::Deserialize<'de> for ArbitraryAttributeValue<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo
|
||||||
|
#[allow(missing_docs)]
|
||||||
impl<'a> AttributeValue<'a> {
|
impl<'a> AttributeValue<'a> {
|
||||||
pub fn as_text(&self) -> Option<&'a str> {
|
pub fn as_text(&self) -> Option<&'a str> {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ pub(crate) mod innerlude {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub use crate::innerlude::{
|
pub use crate::innerlude::{
|
||||||
AnyEvent, Attribute, Component, DioxusElement, DomEdit, Element, ElementId, ElementIdIterator,
|
AnyEvent, Attribute, AttributeValue, Component, DioxusElement, DomEdit, Element, ElementId,
|
||||||
EventHandler, EventPriority, IntoVNode, LazyNodes, Listener, Mutations, NodeFactory,
|
ElementIdIterator, EventHandler, EventPriority, IntoVNode, LazyNodes, Listener, Mutations,
|
||||||
Properties, SchedulerMsg, Scope, ScopeId, ScopeState, TaskId, UiEvent, UserEvent, VComponent,
|
NodeFactory, Properties, SchedulerMsg, Scope, ScopeId, ScopeState, TaskId, UiEvent, UserEvent,
|
||||||
VElement, VFragment, VNode, VPlaceholder, VText, VirtualDom,
|
VComponent, VElement, VFragment, VNode, VPlaceholder, VText, VirtualDom,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The purpose of this module is to alleviate imports of many common types
|
/// The purpose of this module is to alleviate imports of many common types
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use anymap::AnyMap;
|
use anymap::AnyMap;
|
||||||
|
use dioxus_core::AttributeValue;
|
||||||
use dioxus_core::VNode;
|
use dioxus_core::VNode;
|
||||||
use dioxus_core::*;
|
use dioxus_core::*;
|
||||||
use dioxus_core_macro::*;
|
use dioxus_core_macro::*;
|
||||||
@@ -347,7 +348,7 @@ fn state_reduce_parent_called_minimally_on_update() {
|
|||||||
edits: vec![DomEdit::SetAttribute {
|
edits: vec![DomEdit::SetAttribute {
|
||||||
root: 1,
|
root: 1,
|
||||||
field: "width",
|
field: "width",
|
||||||
value: "99%",
|
value: AttributeValue::Text("99%"),
|
||||||
ns: Some("style"),
|
ns: Some("style"),
|
||||||
}],
|
}],
|
||||||
dirty_scopes: fxhash::FxHashSet::default(),
|
dirty_scopes: fxhash::FxHashSet::default(),
|
||||||
@@ -416,7 +417,7 @@ fn state_reduce_child_called_minimally_on_update() {
|
|||||||
edits: vec![DomEdit::SetAttribute {
|
edits: vec![DomEdit::SetAttribute {
|
||||||
root: 4,
|
root: 4,
|
||||||
field: "width",
|
field: "width",
|
||||||
value: "99%",
|
value: AttributeValue::Text("99%"),
|
||||||
ns: Some("style"),
|
ns: Some("style"),
|
||||||
}],
|
}],
|
||||||
dirty_scopes: fxhash::FxHashSet::default(),
|
dirty_scopes: fxhash::FxHashSet::default(),
|
||||||
|
|||||||
Reference in new issue
Block a user