Evan Almloff пре 1 година
родитељ
комит
d5b7a6d15e
2 измењених фајлова са 23 додато и 6 уклоњено
  1. 1 0
      examples/spread.rs
  2. 22 6
      packages/native-core/tests/fuzzing.rs

+ 1 - 0
examples/spread.rs

@@ -20,6 +20,7 @@ fn app(cx: Scope) -> Element {
     }
 }
 
+#[component]
 fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
     render! {
         audio {

+ 22 - 6
packages/native-core/tests/fuzzing.rs

@@ -204,6 +204,20 @@ fn create_random_dynamic_node(cx: &ScopeState, depth: usize) -> DynamicNode {
     }
 }
 
+fn create_random_dynamic_mounted_attr(cx: &ScopeState) -> MountedAttribute {
+    match rand::random::<u8>() % 2 {
+        0 => MountedAttribute::from(
+            &*cx.bump().alloc(
+                (0..(rand::random::<u8>() % 3) as usize)
+                    .map(|_| create_random_dynamic_attr(cx))
+                    .collect::<Vec<_>>(),
+            ),
+        ),
+        1 => MountedAttribute::from(create_random_dynamic_attr(cx)),
+        _ => unreachable!(),
+    }
+}
+
 fn create_random_dynamic_attr(cx: &ScopeState) -> Attribute {
     let value = match rand::random::<u8>() % 6 {
         0 => AttributeValue::Text(Box::leak(
@@ -214,7 +228,6 @@ fn create_random_dynamic_attr(cx: &ScopeState) -> Attribute {
         3 => AttributeValue::Bool(rand::random()),
         4 => cx.any_value(rand::random::<usize>()),
         5 => AttributeValue::None,
-        // Listener(RefCell<Option<ListenerCb<'a>>>),
         _ => unreachable!(),
     };
     Attribute::new(
@@ -273,11 +286,14 @@ fn create_random_element(cx: Scope<DepthProps>) -> Element {
                         .collect();
                     cx.bump().alloc(dynamic_nodes)
                 },
-                dynamic_attrs: cx.bump().alloc(
-                    (0..template.attr_paths.len())
-                        .map(|_| create_random_dynamic_attr(cx))
-                        .collect::<Vec<_>>(),
-                ),
+                dynamic_attrs: cx
+                    .bump()
+                    .alloc(
+                        (0..template.attr_paths.len())
+                            .map(|_| create_random_dynamic_mounted_attr(cx))
+                            .collect::<Vec<_>>(),
+                    )
+                    .as_slice(),
             };
             Some(node)
         }