Ver código fonte

fix: attempt to fix ice

Jonathan Kelley 3 anos atrás
pai
commit
2481cd0
2 arquivos alterados com 13 adições e 32 exclusões
  1. 3 3
      packages/core-macro/src/rsx/element.rs
  2. 10 29
      packages/core/src/nodes.rs

+ 3 - 3
packages/core-macro/src/rsx/element.rs

@@ -204,9 +204,9 @@ impl ToTokens for Element {
         tokens.append_all(quote! {
             __cx.element(
                 dioxus_elements::#name,
-                [ #(#listeners),* ],
-                [ #(#attr),* ],
-                [ #(#children),* ],
+                __cx.bump().alloc([ #(#listeners),* ]),
+                __cx.bump().alloc([ #(#attr),* ]),
+                __cx.bump().alloc([ #(#children),* ]),
                 #key,
             )
         });

+ 10 - 29
packages/core/src/nodes.rs

@@ -447,19 +447,14 @@ impl<'a> NodeFactory<'a> {
         }))
     }
 
-    pub fn element<L, A, V>(
+    pub fn element(
         &self,
         el: impl DioxusElement,
-        listeners: L,
-        attributes: A,
-        children: V,
+        listeners: &'a [Listener<'a>],
+        attributes: &'a [Attribute<'a>],
+        children: &'a [VNode<'a>],
         key: Option<Arguments>,
-    ) -> VNode<'a>
-    where
-        L: 'a + AsRef<[Listener<'a>]>,
-        A: 'a + AsRef<[Attribute<'a>]>,
-        V: 'a + AsRef<[VNode<'a>]>,
-    {
+    ) -> VNode<'a> {
         self.raw_element(
             el.tag_name(),
             el.namespace(),
@@ -470,29 +465,15 @@ impl<'a> NodeFactory<'a> {
         )
     }
 
-    pub fn raw_element<L, A, V>(
+    pub fn raw_element(
         &self,
         tag_name: &'static str,
         namespace: Option<&'static str>,
-        listeners: L,
-        attributes: A,
-        children: V,
+        listeners: &'a [Listener<'a>],
+        attributes: &'a [Attribute<'a>],
+        children: &'a [VNode<'a>],
         key: Option<Arguments>,
-    ) -> VNode<'a>
-    where
-        L: 'a + AsRef<[Listener<'a>]>,
-        A: 'a + AsRef<[Attribute<'a>]>,
-        V: 'a + AsRef<[VNode<'a>]>,
-    {
-        let listeners: &'a L = self.bump.alloc(listeners);
-        let listeners = listeners.as_ref();
-
-        let attributes: &'a A = self.bump.alloc(attributes);
-        let attributes = attributes.as_ref();
-
-        let children: &'a V = self.bump.alloc(children);
-        let children = children.as_ref();
-
+    ) -> VNode<'a> {
         let key = key.map(|f| self.raw_text(f).0);
 
         VNode::Element(self.bump.alloc(VElement {