1
0

forward_spreads.rs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. use dioxus::prelude::*;
  2. // Regression test for https://github.com/DioxusLabs/dioxus/issues/3844
  3. #[test]
  4. fn forward_spreads() {
  5. #[derive(Props, Clone, PartialEq)]
  6. struct Comp1Props {
  7. #[props(extends = GlobalAttributes)]
  8. attributes: Vec<Attribute>,
  9. }
  10. #[component]
  11. fn Comp1(props: Comp1Props) -> Element {
  12. rsx! {
  13. Comp2 {
  14. attributes: props.attributes.clone(),
  15. height: "100%",
  16. }
  17. Comp2 {
  18. height: "100%",
  19. attributes: props.attributes.clone(),
  20. }
  21. }
  22. }
  23. #[derive(Props, Clone, PartialEq)]
  24. struct CompProps2 {
  25. #[props(extends = GlobalAttributes)]
  26. attributes: Vec<Attribute>,
  27. }
  28. #[component]
  29. fn Comp2(props: CompProps2) -> Element {
  30. let attributes = props.attributes;
  31. rsx! {
  32. div {
  33. ..attributes
  34. }
  35. }
  36. }
  37. let merged = || {
  38. rsx! {
  39. Comp1 {
  40. width: "100%"
  41. }
  42. }
  43. };
  44. let dom = VirtualDom::prebuilt(merged);
  45. let html = dioxus_ssr::render(&dom);
  46. assert_eq!(
  47. html,
  48. r#"<div style="width:100%;height:100%;"></div><div style="width:100%;height:100%;"></div>"#
  49. );
  50. }