Merge branch 'master' into binary-protocal

This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-01-04 10:17:10 -08:00
commit a2f44be2a2
76 files changed
+1918 -625

No files matched your search

+1 -1
View File
@@ -190,7 +190,7 @@ pub static BUILTIN_INTERNED_STRINGS: &[&str] = &[
"oncopy",
"oncuechange",
"oncut",
"ondblclick",
"ondoubleclick",
"ondrag",
"ondragend",
"ondragenter",
+25 -12
View File
@@ -45,7 +45,16 @@ impl WebsysDom {
let document = load_document();
let root = match document.get_element_by_id(&cfg.rootname) {
Some(root) => root,
None => document.create_element("body").ok().unwrap(),
None => {
web_sys::console::error_1(
&format!(
"element '#{}' not found. mounting to the body.",
cfg.rootname
)
.into(),
);
document.create_element("body").ok().unwrap()
}
};
let interpreter = Channel::default();
@@ -247,17 +256,21 @@ impl WebsysDom {
i.flush();
for id in to_mount {
let node = get_node(id.0 as u32);
if let Some(element) = node.dyn_ref::<Element>() {
let data: MountedData = element.into();
let data = Rc::new(data);
let _ = self.event_channel.unbounded_send(UiEvent {
name: "mounted".to_string(),
bubbles: false,
element: id,
data,
});
}
self.send_mount_event(id);
}
}
pub(crate) fn send_mount_event(&self, id: ElementId) {
let node = get_node(id.0 as u32);
if let Some(element) = node.dyn_ref::<Element>() {
let data: MountedData = element.into();
let data = Rc::new(data);
let _ = self.event_channel.unbounded_send(UiEvent {
name: "mounted".to_string(),
bubbles: false,
element: id,
data,
});
}
}
}
+14 -5
View File
@@ -125,6 +125,7 @@ impl WebsysDom {
children, attrs, ..
} => {
let mut mounted_id = None;
let mut should_send_mount_event = true;
for attr in *attrs {
if let dioxus_core::TemplateAttribute::Dynamic { id } = attr {
let attribute = &vnode.dynamic_attrs[*id];
@@ -134,16 +135,24 @@ impl WebsysDom {
let name = attribute.name;
if let AttributeValue::Listener(_) = value {
let event_name = &name[2..];
self.interpreter.new_event_listener(
event_name,
id.0 as u32,
event_bubbles(event_name) as u8,
);
match event_name {
"mounted" => should_send_mount_event = true,
_ => {
self.interpreter.new_event_listener(
event_name,
id.0 as u32,
event_bubbles(event_name) as u8,
);
}
}
}
}
}
if let Some(id) = mounted_id {
set_node(hydrated, id, current_child.clone()?);
if should_send_mount_event {
self.send_mount_event(id);
}
}
if !children.is_empty() {
let mut children_current_child = current_child