wip: update readme

This commit is contained in:
Jonathan Kelley committed 2021-11-12 16:06:33 -05:00
1 parent 55e6dd9701
commit 9bd56ee499
4 files changed
+149 -23

No files matched your search

+1 -3
View File
@@ -365,7 +365,6 @@ impl<'bump> DiffState<'bump> {
fn create_text_node(&mut self, vtext: &'bump VText<'bump>, node: &'bump VNode<'bump>) {
let real_id = self.scopes.reserve_node(node);
let parent = self.stack.element_stack.last().unwrap();
self.mutations.create_text_node(vtext.text, real_id);
vtext.dom_id.set(Some(real_id));
@@ -413,7 +412,6 @@ impl<'bump> DiffState<'bump> {
let real_id = self.scopes.reserve_node(node);
self.stack.element_stack.push(real_id);
dom_id.set(Some(real_id));
log::debug!("Parent ID for {:?} set to {:?}", real_id, parent_id.get());
self.mutations.create_element(tag_name, *namespace, real_id);
@@ -545,7 +543,7 @@ impl<'bump> DiffState<'bump> {
&mut self,
old: &'bump VText<'bump>,
new: &'bump VText<'bump>,
old_node: &'bump VNode<'bump>,
_old_node: &'bump VNode<'bump>,
new_node: &'bump VNode<'bump>,
) {
if let Some(root) = old.dom_id.get() {
-10
View File
@@ -261,9 +261,7 @@ pub struct VAnchor {
/// A bump-allocated string slice and metadata.
pub struct VText<'src> {
pub text: &'src str,
pub dom_id: Cell<Option<ElementId>>,
pub is_static: bool,
}
@@ -276,20 +274,12 @@ pub struct VFragment<'src> {
/// An element like a "div" with children, listeners, and attributes.
pub struct VElement<'a> {
pub tag_name: &'static str,
pub namespace: Option<&'static str>,
pub key: Option<&'a str>,
pub dom_id: Cell<Option<ElementId>>,
// Keep the parent id around so we can bubble events through the tree
pub parent_id: Cell<Option<ElementId>>,
pub listeners: &'a [Listener<'a>],
pub attributes: &'a [Attribute<'a>],
pub children: &'a [VNode<'a>],
}
+5 -10
View File
@@ -9,7 +9,6 @@ use fxhash::FxHashSet;
use indexmap::IndexSet;
use smallvec::SmallVec;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::Arc;
use std::task::Poll;
use std::{any::Any, collections::VecDeque};
@@ -293,6 +292,7 @@ impl VirtualDom {
let mut items = scope.items.borrow_mut();
// really this should just be retain_mut but that doesn't exist yet
while let Some(mut task) = items.tasks.pop() {
// todo: does this make sense?
// I don't usually write futures by hand
@@ -312,9 +312,7 @@ impl VirtualDom {
scopes_to_clear.push(*fut);
}
for task in unfinished_tasks.drain(..) {
items.tasks.push(task);
}
items.tasks.extend(unfinished_tasks.drain(..));
}
for scope in scopes_to_clear {
@@ -461,17 +459,14 @@ impl VirtualDom {
);
diff_state.stack.push(DiffInstruction::Diff { new, old });
diff_state.stack.scope_stack.push(scopeid);
let scope = scopes.get_scope(&scopeid).unwrap();
let container = scope.container;
log::debug!("scope {:?} container {:?}", scope.our_arena_idx, container);
diff_state.stack.element_stack.push(container);
diff_state.stack.element_stack.push(scope.container);
}
}
}
let work_completed = diff_state.work(&mut deadline);
if work_completed {
if diff_state.work(&mut deadline) {
let DiffState {
mutations,
seen_scopes,