feat: buff up html allowed attributes

This commit is contained in:
Jonathan Kelley committed 2021-07-12 23:44:20 -04:00
1 parent a05047d01e
commit c79d9ae674
11 files changed
+803 -204

No files matched your search

+1 -2
View File
@@ -5,7 +5,7 @@
//! if the type suppports PartialEq. The Properties trait is used by the rsx! and html! macros to generate the type-safe builder
//! that ensures compile-time required and optional fields on cx.
use crate::innerlude::FC;
use crate::innerlude::{Context, LazyNodes, VNode, FC};
pub trait Properties: Sized {
type Builder;
@@ -50,7 +50,6 @@ pub fn fc_to_builder<T: Properties>(_: FC<T>) -> T::Builder {
///
/// Fragments are incredibly useful when necessary, but *do* add cost in the diffing phase.
/// Try to avoid nesting fragments if you can. Infinitely nested Fragments *will* cause diffing to crash.
use crate::prelude::*;
#[allow(non_upper_case_globals, non_snake_case)]
pub fn Fragment<'a>(cx: Context<'a, ()>) -> VNode<'a> {
cx.render(LazyNodes::new(move |f| f.fragment_from_iter(cx.children())))
+1 -12
View File
@@ -107,18 +107,6 @@ pub trait RealDom<'a> {
fn raw_node_as_any_mut(&self) -> &mut dyn Any;
}
/// The DiffState is a cursor internal to the VirtualDOM's diffing algorithm that allows persistence of state while
/// diffing trees of components. This means we can "re-enter" a subtree of a component by queuing a "NeedToDiff" event.
///
/// By re-entering via NodeDiff, we can connect disparate edits together into a single EditList. This batching of edits
/// leads to very fast re-renders (all done in a single animation frame).
///
/// It also means diffing two trees is only ever complex as diffing a single smaller tree, and then re-entering at a
/// different cursor position.
///
/// The order of these re-entrances is stored in the DiffState itself. The DiffState comes pre-loaded with a set of components
/// that were modified by the eventtrigger. This prevents doubly evaluating components if they were both updated via
/// subscriptions and props changes.
pub struct DiffMachine<'real, 'bump, Dom: RealDom<'bump>> {
pub dom: &'real mut Dom,
pub components: &'bump SharedArena,
@@ -170,6 +158,7 @@ where
self.dom.set_text(new.text);
self.dom.pop();
}
new_node.dom_id.set(root);
}
+31 -34
View File
@@ -8,23 +8,20 @@
//!
//!
#[cfg(feature = "serialize")]
pub mod serialize;
pub use crate::innerlude::{
format_args_f, html, rsx, DioxusElement, DomEdit, EventTrigger, LazyNodes, NodeFactory,
Properties, RealDom, RealDomNode, ScopeIdx, VNode, VNodeKind, VirtualDom, VirtualEvent, FC,
};
pub mod arena;
pub mod bumpframe;
pub mod component;
pub mod context;
pub mod diff;
pub mod error;
pub mod events;
pub mod hooklist;
pub mod nodes;
pub mod scope;
pub mod signals;
pub mod tasks;
pub mod util;
pub mod virtual_dom;
pub mod prelude {
pub use crate::component::{fc_to_builder, Fragment, Properties};
pub use crate::context::Context;
pub use crate::innerlude::DioxusElement;
pub use crate::innerlude::{LazyNodes, NodeFactory, FC};
pub use crate::nodes::VNode;
pub use crate::VirtualDom;
pub use dioxus_core_macro::{format_args_f, html, rsx, Props};
}
// types used internally that are important
pub(crate) mod innerlude {
@@ -43,26 +40,26 @@ pub(crate) mod innerlude {
pub type FC<P> = fn(Context<P>) -> VNode;
pub use dioxus_core_macro::{html, rsx};
}
pub use crate::{
innerlude::{
DioxusElement, DomEdit, LazyNodes, NodeFactory, RealDom, RealDomNode, ScopeIdx, FC,
},
virtual_dom::VirtualDom,
};
pub mod prelude {
pub use crate::component::{fc_to_builder, Fragment, Properties};
pub use crate::context::Context;
pub use crate::innerlude::DioxusElement;
pub use crate::innerlude::{LazyNodes, NodeFactory, FC};
pub use crate::nodes::VNode;
pub use crate::VirtualDom;
pub use dioxus_core_macro::{format_args_f, html, rsx, Props};
pub use dioxus_core_macro::{format_args_f, html, rsx};
}
pub mod exports {
// export important things here
}
pub mod arena;
pub mod bumpframe;
pub mod component;
pub mod context;
pub mod diff;
pub mod error;
pub mod events;
pub mod hooklist;
pub mod nodes;
pub mod scope;
#[cfg(feature = "serialize")]
pub mod serialize;
pub mod signals;
pub mod tasks;
pub mod util;
pub mod virtual_dom;
-1
View File
@@ -1 +0,0 @@
+32 -14
View File
@@ -40,6 +40,7 @@ pub struct VText<'src> {
pub struct VFragment<'src> {
pub children: &'src [VNode<'src>],
pub is_static: bool,
}
pub trait DioxusElement {
@@ -52,6 +53,7 @@ pub trait DioxusElement {
pub struct VElement<'a> {
// tag is always static
pub tag_name: &'static str,
pub namespace: Option<&'static str>,
pub static_listeners: bool,
pub listeners: &'a [Listener<'a>],
@@ -61,9 +63,6 @@ pub struct VElement<'a> {
pub static_children: bool,
pub children: &'a [VNode<'a>],
// namespace is always static
pub namespace: Option<&'static str>,
}
/// An attribute on a DOM node, such as `id="my-thing"` or
@@ -92,14 +91,16 @@ pub struct Listener<'bump> {
/// Only supports the functional syntax
pub struct VComponent<'src> {
pub ass_scope: Cell<Option<ScopeIdx>>,
pub caller: Rc<dyn Fn(&Scope) -> VNode>,
pub children: &'src [VNode<'src>],
pub comparator: Option<&'src dyn Fn(&VComponent) -> bool>,
// a pointer into the bump arena (given by the 'src lifetime)
raw_props: *const (),
// a pointer to the raw fn typ
pub user_fc: *const (),
pub(crate) caller: Rc<dyn Fn(&Scope) -> VNode>,
pub(crate) children: &'src [VNode<'src>],
pub(crate) comparator: Option<&'src dyn Fn(&VComponent) -> bool>,
pub is_static: bool,
// a pointer into the bump arena (given by the 'src lifetime)
pub(crate) raw_props: *const (),
// a pointer to the raw fn typ
pub(crate) user_fc: *const (),
}
/// This struct provides an ergonomic API to quickly build VNodes.
@@ -118,6 +119,20 @@ impl<'a> NodeFactory<'a> {
&self.scope_ref.cur_frame().bump
}
pub const fn const_text(&self, text: &'static str) -> VNodeKind<'static> {
VNodeKind::Text(VText {
is_static: true,
text,
})
}
pub const fn const_fragment(&self, children: &'static [VNode<'static>]) -> VNodeKind<'static> {
VNodeKind::Fragment(VFragment {
children,
is_static: true,
})
}
pub fn static_text(text: &'static str) -> VNode {
VNode {
dom_id: RealDomNode::empty_cell(),
@@ -151,8 +166,6 @@ impl<'a> NodeFactory<'a> {
}
}
pub const fn const_el(&self) {}
pub fn raw_element(
&self,
tag: &'static str,
@@ -279,6 +292,7 @@ impl<'a> NodeFactory<'a> {
key: None,
kind: VNodeKind::Fragment(VFragment {
children: nodes.into_bump_slice(),
is_static: false,
}),
}
}
@@ -385,12 +399,16 @@ impl<'a> Clone for VNode<'a> {
}),
VNodeKind::Fragment(fragment) => VNodeKind::Fragment(VFragment {
children: fragment.children,
is_static: fragment.is_static,
}),
VNodeKind::Component(component) => VNodeKind::Component(component),
VNodeKind::Suspended => VNodeKind::Suspended,
};
todo!()
VNode {
kind,
dom_id: self.dom_id.clone(),
key: self.key.clone(),
}
}
}