fix merge

This commit is contained in:
Evan Almloff committed 2024-01-06 08:58:49 -06:00
1 parent e5df83ceec
commit 5b6f9d6b80
6 files changed
+28 -27

No files matched your search

+2 -5
View File
@@ -15,7 +15,7 @@ fn app(cx: Scope) -> Element {
extra_data: "hello{1}", extra_data: "hello{1}",
extra_data2: "hello{2}", extra_data2: "hello{2}",
height: "10px", height: "10px",
left: 1, left: 1
} }
} }
} }
@@ -23,10 +23,7 @@ fn app(cx: Scope) -> Element {
#[component] #[component]
fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> { fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
render! { render! {
audio { audio { ..cx.props.attributes, "1: {cx.props.extra_data}\n2: {cx.props.extra_data2}" }
..cx.props.attributes,
"1: {cx.props.extra_data}\n2: {cx.props.extra_data2}"
}
} }
} }
+11 -7
View File
@@ -126,10 +126,11 @@ impl<'b> VirtualDom {
.dynamic_attrs .dynamic_attrs
.iter() .iter()
.zip(right_template.dynamic_attrs.iter()) .zip(right_template.dynamic_attrs.iter())
.for_each(|(left_attr, right_attr)| { .enumerate()
.for_each(|(idx, (left_attr, right_attr))| {
// Move over the ID from the old to the new // Move over the ID from the old to the new
let mounted_element = left_attr.mounted_element.get(); let mounted_id = left_attr.mounted_element.get();
right_attr.mounted_element.set(mounted_element); right_attr.mounted_element.set(mounted_id);
match (&left_attr.ty, &right_attr.ty) { match (&left_attr.ty, &right_attr.ty) {
(AttributeType::Single(left), AttributeType::Single(right)) => { (AttributeType::Single(left), AttributeType::Single(right)) => {
@@ -149,9 +150,12 @@ impl<'b> VirtualDom {
left.namespace, left.namespace,
mounted_id, mounted_id,
), ),
std::cmp::Ordering::Greater => { std::cmp::Ordering::Greater => self.write_attribute(
self.write_attribute(right, mounted_id) right_template,
} right,
idx,
mounted_id,
),
std::cmp::Ordering::Equal => { std::cmp::Ordering::Equal => {
self.diff_attribute(left, right, mounted_id) self.diff_attribute(left, right, mounted_id)
} }
@@ -163,7 +167,7 @@ impl<'b> VirtualDom {
} }
(None, Some(_)) => { (None, Some(_)) => {
let right = right_iter.next().unwrap(); let right = right_iter.next().unwrap();
self.write_attribute(right, mounted_id) self.write_attribute(right_template, right, idx, mounted_id)
} }
(None, None) => break, (None, None) => break,
} }
+2 -2
View File
@@ -334,10 +334,10 @@ where
} }
} }
} }
impl<'a> Properties for ErrorBoundaryProps<'a> { impl<'a> Properties<'a> for ErrorBoundaryProps<'a> {
type Builder = ErrorBoundaryPropsBuilder<'a, ((), ())>; type Builder = ErrorBoundaryPropsBuilder<'a, ((), ())>;
const IS_STATIC: bool = false; const IS_STATIC: bool = false;
fn builder() -> Self::Builder { fn builder(_: &'a ScopeState) -> Self::Builder {
ErrorBoundaryProps::builder() ErrorBoundaryProps::builder()
} }
unsafe fn memoize(&self, _: &Self) -> bool { unsafe fn memoize(&self, _: &Self) -> bool {
+5 -6
View File
@@ -90,12 +90,11 @@ pub mod prelude {
pub use crate::innerlude::{ pub use crate::innerlude::{
consume_context, consume_context_from_scope, current_scope_id, fc_to_builder, has_context, consume_context, consume_context_from_scope, current_scope_id, fc_to_builder, has_context,
provide_context, provide_context_to_scope, provide_root_context, push_future, provide_context, provide_context_to_scope, provide_root_context, push_future,
remove_future, schedule_update_any, spawn, spawn_forever, suspend, throw, remove_future, schedule_update_any, spawn, spawn_forever, suspend, use_error_boundary,
use_error_boundary, AnyValue, AnyValue, Attribute, AttributeType, Component, Element, AnyValue, Attribute, AttributeType, Component, Element, ErrorBoundary, Event, EventHandler,
ErrorBoundary, Event, EventHandler, Fragment, HasAttributes, IntoAttributeValue, Fragment, HasAttributes, IntoAttributeValue, IntoDynNode, LazyNodes, MountedAttribute,
IntoDynNode, LazyNodes, MountedAttribute, Properties, Runtime, RuntimeGuard, Scope, Properties, Runtime, RuntimeGuard, Scope, ScopeId, ScopeState, Scoped, TaskId, Template,
ScopeId, ScopeState, Scoped, TaskId, Template, TemplateAttribute, TemplateNode, Throw, TemplateAttribute, TemplateNode, Throw, VNode, VirtualDom,
VNode, VirtualDom,
}; };
} }
+1 -1
View File
@@ -92,7 +92,7 @@ impl<'a> VNode<'a> {
template: Template<'static>, template: Template<'static>,
root_ids: bumpalo::collections::Vec<'a, ElementId>, root_ids: bumpalo::collections::Vec<'a, ElementId>,
dynamic_nodes: &'a [DynamicNode<'a>], dynamic_nodes: &'a [DynamicNode<'a>],
dynamic_attrs: &'a [Attribute<'a>], dynamic_attrs: &'a [MountedAttribute<'a>],
) -> Self { ) -> Self {
Self { Self {
key, key,
+7 -6
View File
@@ -5,13 +5,13 @@
use crate::{ use crate::{
any_props::VProps, any_props::VProps,
arena::{ElementId, ElementRef}, arena::{ElementId, ElementRef},
innerlude::{AttributeType, DirtyScope, ErrorBoundary, Mutations, Scheduler, SchedulerMsg}, innerlude::{DirtyScope, ErrorBoundary, Mutations, Scheduler, SchedulerMsg},
mutations::Mutation, mutations::Mutation,
nodes::RenderReturn, nodes::RenderReturn,
nodes::{Template, TemplateId}, nodes::{Template, TemplateId},
runtime::{Runtime, RuntimeGuard}, runtime::{Runtime, RuntimeGuard},
scopes::{ScopeId, ScopeState}, scopes::{ScopeId, ScopeState},
Attribute, AttributeValue, Element, Event, Scope, VNode, AttributeValue, Element, Event, Scope, VNode,
}; };
use futures_util::{pin_mut, StreamExt}; use futures_util::{pin_mut, StreamExt};
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
@@ -371,7 +371,6 @@ impl VirtualDom {
.get(parent_path.template.0) .get(parent_path.template.0)
.cloned() .cloned()
.map(|el| (*parent_path, el)); .map(|el| (*parent_path, el));
let mut listeners = vec![];
// We will clone this later. The data itself is wrapped in RC to be used in callbacks if required // We will clone this later. The data itself is wrapped in RC to be used in callbacks if required
let uievent = Event { let uievent = Event {
@@ -383,6 +382,8 @@ impl VirtualDom {
if bubbles { if bubbles {
// Loop through each dynamic attribute (in a depth first order) in this template before moving up to the template's parent. // Loop through each dynamic attribute (in a depth first order) in this template before moving up to the template's parent.
while let Some((path, el_ref)) = parent_node { while let Some((path, el_ref)) = parent_node {
let mut listeners = vec![];
// safety: we maintain references of all vnodes in the element slab // safety: we maintain references of all vnodes in the element slab
let template = unsafe { el_ref.unwrap().as_ref() }; let template = unsafe { el_ref.unwrap().as_ref() };
let node_template = template.template.get(); let node_template = template.template.get();
@@ -396,7 +397,7 @@ impl VirtualDom {
attr.ty.for_each(|attribute| { attr.ty.for_each(|attribute| {
if attribute.name.trim_start_matches("on") == name { if attribute.name.trim_start_matches("on") == name {
if let AttributeValue::Listener(listener) = &attribute.value { if let AttributeValue::Listener(listener) = &attribute.value {
listeners.push(&listener); listeners.push(listener);
} }
} }
}); });
@@ -412,7 +413,7 @@ impl VirtualDom {
// Now that we've accumulated all the parent attributes for the target element, call them in reverse order // Now that we've accumulated all the parent attributes for the target element, call them in reverse order
// We check the bubble state between each call to see if the event has been stopped from bubbling // We check the bubble state between each call to see if the event has been stopped from bubbling
for listener in listeners.drain(..).rev() { for listener in listeners.into_iter().rev() {
let origin = path.scope; let origin = path.scope;
self.runtime.scope_stack.borrow_mut().push(origin); self.runtime.scope_stack.borrow_mut().push(origin);
self.runtime.rendering.set(false); self.runtime.rendering.set(false);
@@ -451,7 +452,7 @@ impl VirtualDom {
let mut should_stop = false; let mut should_stop = false;
attr.ty.for_each(|attribute| { attr.ty.for_each(|attribute| {
if attribute.name.trim_start_matches("on") == name { if attribute.name.trim_start_matches("on") == name {
if let AttributeValue::Listener(listener) = &attr.value { if let AttributeValue::Listener(listener) = &attribute.value {
let origin = path.scope; let origin = path.scope;
self.runtime.scope_stack.borrow_mut().push(origin); self.runtime.scope_stack.borrow_mut().push(origin);
self.runtime.rendering.set(false); self.runtime.rendering.set(false);