mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-26 12:27:22 +00:00
* Fix hot reloading components with keys * include component formatted segment keys, but not dynamic component value * extend each head component with the corresponding element * Allow spreading custom attributes into components * Fix component_literal_dyn_idx index * add a new test for hot reloading components with keys * FIx script without body warning and rendering styles with a href set * fix clippy
43 lines
909 B
Rust
43 lines
909 B
Rust
use dioxus::prelude::*;
|
|
|
|
#[test]
|
|
fn spread() {
|
|
let dom = VirtualDom::prebuilt(app);
|
|
let html = dioxus_ssr::render(&dom);
|
|
|
|
assert_eq!(
|
|
html,
|
|
r#"<audio data-custom-attribute="value" style="width:10px;height:10px;left:1;">1: hello1
|
|
2: hello2</audio>"#
|
|
);
|
|
}
|
|
|
|
fn app() -> Element {
|
|
rsx! {
|
|
SpreadableComponent {
|
|
width: "10px",
|
|
extra_data: "hello{1}",
|
|
extra_data2: "hello{2}",
|
|
height: "10px",
|
|
left: 1,
|
|
"data-custom-attribute": "value",
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Props, PartialEq, Clone)]
|
|
struct Props {
|
|
#[props(extends = GlobalAttributes)]
|
|
attributes: Vec<Attribute>,
|
|
|
|
extra_data: String,
|
|
|
|
extra_data2: String,
|
|
}
|
|
|
|
#[component]
|
|
fn SpreadableComponent(props: Props) -> Element {
|
|
rsx! {
|
|
audio { ..props.attributes, "1: {props.extra_data}\n2: {props.extra_data2}" }
|
|
}
|
|
}
|