From c1280acc0e1d469555d96f84710fd71d41c8d3ab Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Tue, 19 Jul 2022 18:50:05 +0500 Subject: [PATCH] remove uneeded test & todo this test is done at compile time. there's no node_ref field so it can't be set --- .../yew-macro/src/html_tree/html_component.rs | 2 - packages/yew/tests/node_ref.rs | 72 ------------------- 2 files changed, 74 deletions(-) delete mode 100644 packages/yew/tests/node_ref.rs diff --git a/packages/yew-macro/src/html_tree/html_component.rs b/packages/yew-macro/src/html_tree/html_component.rs index 0c09e011c29..0a69eaf979b 100644 --- a/packages/yew-macro/src/html_tree/html_component.rs +++ b/packages/yew-macro/src/html_tree/html_component.rs @@ -106,8 +106,6 @@ impl ToTokens for HtmlComponent { Some(quote! { ::yew::html::ChildrenRenderer::new(#children) }) }; let build_props = props.build_properties_tokens(&props_ty, children_renderer); - // todo: this shouldn't exist for components - let _node_ref = props.special().wrap_node_ref_attr(); let key = props.special().wrap_key_attr(); let use_close_tag = close .as_ref() diff --git a/packages/yew/tests/node_ref.rs b/packages/yew/tests/node_ref.rs deleted file mode 100644 index 06b2281526b..00000000000 --- a/packages/yew/tests/node_ref.rs +++ /dev/null @@ -1,72 +0,0 @@ -#![cfg(target_arch = "wasm32")] - -mod common; - -use wasm_bindgen_test::*; -use yew::platform::sync::mpsc; -use yew::prelude::*; - -wasm_bindgen_test_configure!(run_in_browser); - -#[derive(PartialEq, Clone, Properties)] -struct CountProps { - count: u32, -} - -#[function_component] -fn Count(props: &CountProps) -> Html { - html! { - <> -

{ "Current Count:"}

-

{props.count}

- - } -} - -#[derive(Clone, Properties)] -struct AppProps { - node_ref: NodeRef, - tx: mpsc::Sender<()>, -} - -impl PartialEq for AppProps { - fn eq(&self, _other: &Self) -> bool { - false - } -} - -#[function_component] -fn App(props: &AppProps) -> Html { - let state = use_state(|| 0); - let node_ref = props.node_ref.clone(); - - { - let node_ref = node_ref.clone(); - let tx = props.tx.clone(); - use_effect(move || { - yew::platform::spawn_local(async move { - tx.send(()).await.unwrap(); - }); - || {} - }) - } - - html!( - <> - - - ) -} - -#[wasm_bindgen_test] -async fn component_has_no_node_ref() { - let (tx, mut rx) = mpsc::channel::<()>(1); - let node_ref = NodeRef::default(); - let props = AppProps { - node_ref: node_ref.clone(), - tx, - }; - yew::Renderer::::with_root_and_props(common::output_element(), props).render(); - rx.recv().await.unwrap(); - assert!(node_ref.get().is_none()); -}