chore: continue to clean things up

This commit is contained in:
Jonathan Kelley committed 2022-12-01 01:08:49 -05:00
1 parent 85657d3906
commit 11a45c8ef0
5 files changed
+23 -50

No files matched your search

+11 -8
View File
@@ -64,8 +64,9 @@ impl WebsysDom {
}
fn create_template_node(&self, v: &TemplateNode) -> web_sys::Node {
use TemplateNode::*;
match v {
TemplateNode::Element {
Element {
tag,
namespace,
attrs,
@@ -86,6 +87,12 @@ impl WebsysDom {
} = attr
{
match namespace {
Some(ns) if *ns == "style" => el
.dyn_ref::<HtmlElement>()
.unwrap()
.style()
.set_property(name, value)
.unwrap(),
Some(ns) => el.set_attribute_ns(Some(ns), name, value).unwrap(),
None => el.set_attribute(name, value).unwrap(),
}
@@ -99,9 +106,9 @@ impl WebsysDom {
el.dyn_into().unwrap()
}
TemplateNode::Text(t) => self.document.create_text_node(t).dyn_into().unwrap(),
TemplateNode::DynamicText(_) => self.document.create_text_node("p").dyn_into().unwrap(),
TemplateNode::Dynamic(_) => {
Text(t) => self.document.create_text_node(t).dyn_into().unwrap(),
DynamicText(_) => self.document.create_text_node("p").dyn_into().unwrap(),
Dynamic(_) => {
let el = self.document.create_element("pre").unwrap();
el.toggle_attribute("hidden");
el.dyn_into().unwrap()
@@ -112,7 +119,6 @@ impl WebsysDom {
pub fn apply_edits(&mut self, mut edits: Vec<Mutation>) {
use Mutation::*;
let i = &self.interpreter;
for edit in edits.drain(..) {
match edit {
AssignId { path, id } => i.AssignId(path, id.0 as u32),
@@ -145,9 +151,6 @@ impl WebsysDom {
RemoveEventListener { name, id } => i.RemoveEventListener(name, id.0 as u32),
Remove { id } => i.Remove(id.0 as u32),
PushRoot { id } => i.PushRoot(id.0 as u32),
// Mutation::RemoveEventListener { root, name: event } => self
// .interpreter
// .RemoveEventListener(root, event, event_bubbles(event)),
}
}
}
+2 -1
View File
@@ -197,6 +197,8 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
websys_dom.load_templates(&edits.templates);
websys_dom.apply_edits(edits.edits);
// the mutations come back with nothing - we need to actually mount them
websys_dom.mount();
let mut work_loop = ric_raf::RafLoop::new();
@@ -243,7 +245,6 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
let deadline = work_loop.wait_for_idle_time().await;
// run the virtualdom work phase until the frame deadline is reached
// let deadline = gloo_timers::future::sleep(Duration::from_millis(10000));
let edits = dom.render_with_deadline(deadline).await;
// wait for the animation frame to fire so we can apply our changes