Fix: expose AttributeValue; update tests to pass

This commit is contained in:
Reinis Mazeiks committed 2022-05-07 13:43:40 +03:00
1 parent 2eca71e644
commit 85aa4584ff
3 files changed
+13 -6

No files matched your search

+6
View File
@@ -1,9 +1,11 @@
use std::fmt::Formatter;
/// Possible values for an attribute
// trying to keep values at 3 bytes
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serialize", serde(untagged))]
#[derive(Clone, Debug, PartialEq)]
#[allow(missing_docs)]
pub enum AttributeValue<'a> {
Text(&'a str),
Float32(f32),
@@ -26,6 +28,8 @@ pub enum AttributeValue<'a> {
Any(ArbitraryAttributeValue<'a>),
}
// todo
#[allow(missing_docs)]
impl<'a> AttributeValue<'a> {
pub fn is_truthy(&self) -> bool {
match self {
@@ -113,6 +117,8 @@ impl<'de, 'a> serde::Deserialize<'de> for ArbitraryAttributeValue<'a> {
}
}
// todo
#[allow(missing_docs)]
impl<'a> AttributeValue<'a> {
pub fn as_text(&self) -> Option<&'a str> {
match self {
+4 -4
View File
@@ -73,10 +73,10 @@ pub(crate) mod innerlude {
}
pub use crate::innerlude::{
AnyEvent, Attribute, Component, DioxusElement, DomEdit, Element, ElementId, ElementIdIterator,
EventHandler, EventPriority, IntoVNode, LazyNodes, Listener, Mutations, NodeFactory,
Properties, SchedulerMsg, Scope, ScopeId, ScopeState, TaskId, UiEvent, UserEvent, VComponent,
VElement, VFragment, VNode, VPlaceholder, VText, VirtualDom,
AnyEvent, Attribute, AttributeValue, Component, DioxusElement, DomEdit, Element, ElementId,
ElementIdIterator, EventHandler, EventPriority, IntoVNode, LazyNodes, Listener, Mutations,
NodeFactory, Properties, SchedulerMsg, Scope, ScopeId, ScopeState, TaskId, UiEvent, UserEvent,
VComponent, VElement, VFragment, VNode, VPlaceholder, VText, VirtualDom,
};
/// The purpose of this module is to alleviate imports of many common types