1
0

spread.rs 909 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. use dioxus::prelude::*;
  2. #[test]
  3. fn spread() {
  4. let dom = VirtualDom::prebuilt(app);
  5. let html = dioxus_ssr::render(&dom);
  6. assert_eq!(
  7. html,
  8. r#"<audio data-custom-attribute="value" style="width:10px;height:10px;left:1;">1: hello1
  9. 2: hello2</audio>"#
  10. );
  11. }
  12. fn app() -> Element {
  13. rsx! {
  14. SpreadableComponent {
  15. width: "10px",
  16. extra_data: "hello{1}",
  17. extra_data2: "hello{2}",
  18. height: "10px",
  19. left: 1,
  20. "data-custom-attribute": "value",
  21. }
  22. }
  23. }
  24. #[derive(Props, PartialEq, Clone)]
  25. struct Props {
  26. #[props(extends = GlobalAttributes)]
  27. attributes: Vec<Attribute>,
  28. extra_data: String,
  29. extra_data2: String,
  30. }
  31. #[component]
  32. fn SpreadableComponent(props: Props) -> Element {
  33. rsx! {
  34. audio { ..props.attributes, "1: {props.extra_data}\n2: {props.extra_data2}" }
  35. }
  36. }