feat: buff up html allowed attributes
This commit is contained in:
1 parent
a05047d01e
commit
c79d9ae674
11 files changed
+803
-204
No files matched your search
@@ -41,5 +41,5 @@ smallvec = "1.6.1"
|
||||
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["serialize"]
|
||||
serialize = ["slotmap/serde", "serde"]
|
||||
@@ -1,20 +1,20 @@
|
||||
fn main() {}
|
||||
|
||||
use dioxus::*;
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_core::prelude::*;
|
||||
// use dioxus::*;
|
||||
// use dioxus_core as dioxus;
|
||||
// use dioxus_core::prelude::*;
|
||||
|
||||
static Example: FC<()> = |cx| {
|
||||
let list = (0..10).map(|f| LazyNodes::new(move |f| todo!()));
|
||||
// static Example: FC<()> = |cx| {
|
||||
// let list = (0..10).map(|f| LazyNodes::new(move |f| todo!()));
|
||||
|
||||
cx.render(LazyNodes::new(move |cx| {
|
||||
let bump = cx.bump();
|
||||
cx.raw_element("div")
|
||||
.children([
|
||||
cx.text(format_args!("hello")),
|
||||
cx.text(format_args!("hello")),
|
||||
cx.fragment_from_iter(list),
|
||||
])
|
||||
.finish()
|
||||
}))
|
||||
};
|
||||
// cx.render(LazyNodes::new(move |cx| {
|
||||
// let bump = cx.bump();
|
||||
// cx.raw_element("div")
|
||||
// .children([
|
||||
// cx.text(format_args!("hello")),
|
||||
// cx.text(format_args!("hello")),
|
||||
// cx.fragment_from_iter(list),
|
||||
// ])
|
||||
// .finish()
|
||||
// }))
|
||||
// };
|
||||
@@ -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())))
|
||||
|
||||
@@ -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
@@ -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 +0,0 @@
|
||||
|
||||
+32
-14
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+709
-113
File diff suppressed because it is too large.
Load diff
@@ -8,7 +8,7 @@
|
||||
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
use dioxus_core::{nodes::VNode, virtual_dom::VirtualDom};
|
||||
use dioxus_core::*;
|
||||
|
||||
pub fn render_root(vdom: &VirtualDom) -> String {
|
||||
format!("{:}", TextRenderer::new(vdom))
|
||||
@@ -69,8 +69,8 @@ impl<'a> TextRenderer<'a> {
|
||||
}
|
||||
|
||||
fn html_render(&self, node: &VNode, f: &mut std::fmt::Formatter, il: u16) -> std::fmt::Result {
|
||||
match node {
|
||||
VNode::Text(text) => {
|
||||
match &node.kind {
|
||||
VNodeKind::Text(text) => {
|
||||
if self.cfg.indent {
|
||||
for _ in 0..il {
|
||||
write!(f, " ")?;
|
||||
@@ -78,7 +78,7 @@ impl<'a> TextRenderer<'a> {
|
||||
}
|
||||
write!(f, "{}", text.text)?
|
||||
}
|
||||
VNode::Element(el) => {
|
||||
VNodeKind::Element(el) => {
|
||||
if self.cfg.indent {
|
||||
for _ in 0..il {
|
||||
write!(f, " ")?;
|
||||
@@ -112,12 +112,12 @@ impl<'a> TextRenderer<'a> {
|
||||
write!(f, "\n")?;
|
||||
}
|
||||
}
|
||||
VNode::Fragment(frag) => {
|
||||
VNodeKind::Fragment(frag) => {
|
||||
for child in frag.children {
|
||||
self.html_render(child, f, il + 1)?;
|
||||
}
|
||||
}
|
||||
VNode::Component(vcomp) => {
|
||||
VNodeKind::Component(vcomp) => {
|
||||
let idx = vcomp.ass_scope.get().unwrap();
|
||||
|
||||
let new_node = self
|
||||
@@ -130,7 +130,7 @@ impl<'a> TextRenderer<'a> {
|
||||
|
||||
self.html_render(new_node, f, il + 1)?;
|
||||
}
|
||||
VNode::Suspended { .. } => todo!(),
|
||||
VNodeKind::Suspended => todo!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_core::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus_webview::launch(App, |f| f.with_focus().with_maximized(true)).expect("Failed");
|
||||
}
|
||||
@@ -11,8 +14,6 @@ static App: FC<()> = |cx| {
|
||||
))
|
||||
};
|
||||
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_core::prelude::*;
|
||||
mod dioxus_elements {
|
||||
use super::*;
|
||||
pub struct div;
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::ops::{Deref, DerefMut};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use dioxus_core::virtual_dom::VirtualDom;
|
||||
use dioxus_core::{prelude::*, serialize::DomEdit};
|
||||
use dioxus_core::*;
|
||||
|
||||
use wry::{
|
||||
application::window::{Window, WindowBuilder},
|
||||
webview::{RpcRequest, RpcResponse},
|
||||
|
||||
Reference in new issue
Block a user