polish: examples
This commit is contained in:
1 parent
4b6ca05f2c
commit
1a2f91ed91
19 files changed
+327
-183
No files matched your search
@@ -461,9 +461,10 @@ impl<'bump> DiffMachine<'bump> {
|
||||
let mut please_commit = |edits: &mut Vec<DomEdit>| {
|
||||
if !has_comitted {
|
||||
has_comitted = true;
|
||||
if let Some(root) = root {
|
||||
edits.push(PushRoot { id: root.as_u64() });
|
||||
}
|
||||
log::info!("planning on committing... {:#?}, {:#?}", old, new);
|
||||
edits.push(PushRoot {
|
||||
id: root.unwrap().as_u64(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -475,7 +476,12 @@ impl<'bump> DiffMachine<'bump> {
|
||||
// TODO: take a more efficient path than this
|
||||
if old.attributes.len() == new.attributes.len() {
|
||||
for (old_attr, new_attr) in old.attributes.iter().zip(new.attributes.iter()) {
|
||||
if old_attr.value != new_attr.value || old_attr.is_volatile {
|
||||
log::info!("checking attribute");
|
||||
if old_attr.value != new_attr.value {
|
||||
please_commit(&mut self.mutations.edits);
|
||||
self.mutations.set_attribute(new_attr);
|
||||
} else if new_attr.is_volatile {
|
||||
log::debug!("setting due to volatile atttributes");
|
||||
please_commit(&mut self.mutations.edits);
|
||||
self.mutations.set_attribute(new_attr);
|
||||
}
|
||||
|
||||
@@ -264,8 +264,10 @@ pub mod on {
|
||||
ClipboardEventInner(ClipboardEvent): [
|
||||
/// Called when "copy"
|
||||
oncopy
|
||||
|
||||
/// oncut
|
||||
oncut
|
||||
|
||||
/// onpaste
|
||||
onpaste
|
||||
];
|
||||
@@ -305,7 +307,7 @@ pub mod on {
|
||||
/// onchange
|
||||
onchange
|
||||
|
||||
/// oninput
|
||||
/// oninput handler
|
||||
oninput
|
||||
|
||||
/// oninvalid
|
||||
@@ -446,22 +448,31 @@ pub mod on {
|
||||
PointerEventInner(PointerEvent): [
|
||||
/// pointerdown
|
||||
onpointerdown
|
||||
|
||||
/// pointermove
|
||||
onpointermove
|
||||
|
||||
/// pointerup
|
||||
onpointerup
|
||||
|
||||
/// pointercancel
|
||||
onpointercancel
|
||||
|
||||
/// gotpointercapture
|
||||
ongotpointercapture
|
||||
|
||||
/// lostpointercapture
|
||||
onlostpointercapture
|
||||
|
||||
/// pointerenter
|
||||
onpointerenter
|
||||
|
||||
/// pointerleave
|
||||
onpointerleave
|
||||
|
||||
/// pointerover
|
||||
onpointerover
|
||||
|
||||
/// pointerout
|
||||
onpointerout
|
||||
];
|
||||
@@ -474,10 +485,13 @@ pub mod on {
|
||||
TouchEventInner(TouchEvent): [
|
||||
/// ontouchcancel
|
||||
ontouchcancel
|
||||
|
||||
/// ontouchend
|
||||
ontouchend
|
||||
|
||||
/// ontouchmove
|
||||
ontouchmove
|
||||
|
||||
/// ontouchstart
|
||||
ontouchstart
|
||||
];
|
||||
@@ -490,48 +504,70 @@ pub mod on {
|
||||
MediaEventInner(MediaEvent): [
|
||||
///abort
|
||||
onabort
|
||||
|
||||
///canplay
|
||||
oncanplay
|
||||
|
||||
///canplaythrough
|
||||
oncanplaythrough
|
||||
|
||||
///durationchange
|
||||
ondurationchange
|
||||
|
||||
///emptied
|
||||
onemptied
|
||||
|
||||
///encrypted
|
||||
onencrypted
|
||||
|
||||
///ended
|
||||
onended
|
||||
|
||||
///error
|
||||
onerror
|
||||
|
||||
///loadeddata
|
||||
onloadeddata
|
||||
|
||||
///loadedmetadata
|
||||
onloadedmetadata
|
||||
|
||||
///loadstart
|
||||
onloadstart
|
||||
|
||||
///pause
|
||||
onpause
|
||||
|
||||
///play
|
||||
onplay
|
||||
|
||||
///playing
|
||||
onplaying
|
||||
|
||||
///progress
|
||||
onprogress
|
||||
|
||||
///ratechange
|
||||
onratechange
|
||||
|
||||
///seeked
|
||||
onseeked
|
||||
|
||||
///seeking
|
||||
onseeking
|
||||
|
||||
///stalled
|
||||
onstalled
|
||||
|
||||
///suspend
|
||||
onsuspend
|
||||
|
||||
///timeupdate
|
||||
ontimeupdate
|
||||
|
||||
///volumechange
|
||||
onvolumechange
|
||||
|
||||
///waiting
|
||||
onwaiting
|
||||
];
|
||||
@@ -539,8 +575,10 @@ pub mod on {
|
||||
AnimationEventInner(AnimationEvent): [
|
||||
/// onanimationstart
|
||||
onanimationstart
|
||||
|
||||
/// onanimationend
|
||||
onanimationend
|
||||
|
||||
/// onanimationiteration
|
||||
onanimationiteration
|
||||
];
|
||||
|
||||
@@ -197,6 +197,21 @@ pub struct VElement<'a> {
|
||||
pub children: &'a [VNode<'a>],
|
||||
}
|
||||
|
||||
impl Debug for VElement<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("VElement")
|
||||
.field("tag_name", &self.tag_name)
|
||||
.field("namespace", &self.namespace)
|
||||
.field("key", &self.key)
|
||||
.field("dom_id", &self.dom_id)
|
||||
.field("parent_id", &self.parent_id)
|
||||
.field("listeners", &self.listeners.len())
|
||||
.field("attributes", &self.attributes)
|
||||
.field("children", &self.children)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait for any generic Dioxus Element.
|
||||
///
|
||||
/// This trait provides the ability to use custom elements in the `rsx!` macro.
|
||||
@@ -429,11 +444,6 @@ impl<'a> NodeFactory<'a> {
|
||||
is_volatile: bool,
|
||||
) -> Attribute<'a> {
|
||||
let (value, is_static) = self.raw_text(val);
|
||||
let is_volatile = match name {
|
||||
"value" | "checked" | "selected" => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
Attribute {
|
||||
name,
|
||||
value,
|
||||
|
||||
@@ -72,6 +72,7 @@ use crate::heuristics::*;
|
||||
use crate::innerlude::*;
|
||||
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||
use futures_util::{pin_mut, stream::FuturesUnordered, Future, FutureExt, StreamExt};
|
||||
use fxhash::FxHashMap;
|
||||
use fxhash::FxHashSet;
|
||||
use indexmap::IndexSet;
|
||||
use slab::Slab;
|
||||
@@ -357,6 +358,8 @@ impl Scheduler {
|
||||
let shared = self.pool.clone();
|
||||
let mut machine = unsafe { saved_state.promote(&shared) };
|
||||
|
||||
let mut ran_scopes = FxHashSet::default();
|
||||
|
||||
if machine.stack.is_empty() {
|
||||
let shared = self.pool.clone();
|
||||
|
||||
@@ -367,11 +370,18 @@ impl Scheduler {
|
||||
});
|
||||
|
||||
if let Some(scopeid) = self.dirty_scopes.pop() {
|
||||
let component = self.pool.get_scope(scopeid).unwrap();
|
||||
let (old, new) = (component.frames.wip_head(), component.frames.fin_head());
|
||||
// let (old, new) = (component.frames.wip_head(), component.frames.fin_head());
|
||||
machine.stack.scope_stack.push(scopeid);
|
||||
machine.stack.push(DiffInstruction::Diff { new, old });
|
||||
log::info!("handlng dirty scope {:#?}", scopeid);
|
||||
if !ran_scopes.contains(&scopeid) {
|
||||
ran_scopes.insert(scopeid);
|
||||
|
||||
let mut component = self.pool.get_scope_mut(scopeid).unwrap();
|
||||
if component.run_scope(&self.pool) {
|
||||
let (old, new) = (component.frames.wip_head(), component.frames.fin_head());
|
||||
// let (old, new) = (component.frames.wip_head(), component.frames.fin_head());
|
||||
machine.stack.scope_stack.push(scopeid);
|
||||
machine.stack.push(DiffInstruction::Diff { new, old });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,15 +482,7 @@ impl Scheduler {
|
||||
while let Ok(Some(dirty_scope)) = self.receiver.try_next() {
|
||||
match dirty_scope {
|
||||
SchedulerMsg::Immediate(im) => {
|
||||
log::debug!("Handling immediate {:?}", im);
|
||||
|
||||
if let Some(scope) = self.pool.get_scope_mut(im) {
|
||||
if scope.run_scope(&self.pool) {
|
||||
self.dirty_scopes.insert(im);
|
||||
} else {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
self.dirty_scopes.insert(im);
|
||||
}
|
||||
SchedulerMsg::UiEvent(e) => self.ui_events.push_back(e),
|
||||
SchedulerMsg::Task(_) => todo!(),
|
||||
|
||||
Reference in new issue
Block a user