Implement some clippy fixes
This commit is contained in:
11 files changed
+103
-133
No files matched your search
@@ -25,8 +25,6 @@ serde = { version = "1", features = ["derive"], optional = true }
|
||||
[dev-dependencies]
|
||||
tokio = { workspace = true, features = ["full"] }
|
||||
dioxus = { workspace = true }
|
||||
dioxus-core = { workspace = true }
|
||||
dioxus-html = { workspace = true, features = ["serialize"] }
|
||||
pretty_assertions = "1.3.0"
|
||||
rand = "0.8.5"
|
||||
dioxus-ssr = { workspace = true }
|
||||
|
||||
@@ -738,6 +738,7 @@ impl PartialEq for AttributeValue {
|
||||
(Self::Bool(l0), Self::Bool(r0)) => l0 == r0,
|
||||
(Self::Listener(_), Self::Listener(_)) => true,
|
||||
(Self::Any(l0), Self::Any(r0)) => l0.as_ref().any_cmp(r0.as_ref()),
|
||||
(Self::None, Self::None) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use dioxus::dioxus_core::Mutation::*;
|
||||
use dioxus::dioxus_core::{AttributeValue, ElementId, NoOpMutations};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core::{AttributeValue, ElementId, NoOpMutations};
|
||||
|
||||
#[test]
|
||||
fn text_diff() {
|
||||
@@ -85,119 +85,99 @@ fn element_swap() {
|
||||
|
||||
#[test]
|
||||
fn attribute_diff() {
|
||||
// fn app() -> Element {
|
||||
// let gen = cx.generation();
|
||||
fn app() -> Element {
|
||||
let gen = generation();
|
||||
|
||||
// // attributes have to be sorted by name
|
||||
// let attrs = match gen % 5 {
|
||||
// 0 => cx.bump().alloc([Attribute::new(
|
||||
// "a",
|
||||
// AttributeValue::Text("hello".into()),
|
||||
// None,
|
||||
// false,
|
||||
// )]) as &[Attribute],
|
||||
// 1 => cx.bump().alloc([
|
||||
// Attribute::new("a", AttributeValue::Text("hello".into()), None, false),
|
||||
// Attribute::new("b", AttributeValue::Text("hello".into()), None, false),
|
||||
// Attribute::new("c", AttributeValue::Text("hello".into()), None, false),
|
||||
// ]) as &[Attribute],
|
||||
// 2 => cx.bump().alloc([
|
||||
// Attribute::new("c", AttributeValue::Text("hello".into()), None, false),
|
||||
// Attribute::new("d", AttributeValue::Text("hello".into()), None, false),
|
||||
// Attribute::new("e", AttributeValue::Text("hello".into()), None, false),
|
||||
// ]) as &[Attribute],
|
||||
// 3 => cx.bump().alloc([Attribute::new(
|
||||
// "d",
|
||||
// AttributeValue::Text("world".into()),
|
||||
// None,
|
||||
// false,
|
||||
// )]) as &[Attribute],
|
||||
// _ => unreachable!(),
|
||||
// };
|
||||
// attributes have to be sorted by name
|
||||
let attrs = match gen % 5 {
|
||||
0 => vec![Attribute::new(
|
||||
"a",
|
||||
AttributeValue::Text("hello".into()),
|
||||
None,
|
||||
false,
|
||||
)],
|
||||
1 => vec![
|
||||
Attribute::new("a", AttributeValue::Text("hello".into()), None, false),
|
||||
Attribute::new("b", AttributeValue::Text("hello".into()), None, false),
|
||||
Attribute::new("c", AttributeValue::Text("hello".into()), None, false),
|
||||
],
|
||||
2 => vec![
|
||||
Attribute::new("c", AttributeValue::Text("hello".into()), None, false),
|
||||
Attribute::new("d", AttributeValue::Text("hello".into()), None, false),
|
||||
Attribute::new("e", AttributeValue::Text("hello".into()), None, false),
|
||||
],
|
||||
3 => vec![Attribute::new(
|
||||
"d",
|
||||
AttributeValue::Text("world".into()),
|
||||
None,
|
||||
false,
|
||||
)],
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
// cx.render(rsx!(
|
||||
// div {
|
||||
// ..*attrs,
|
||||
// "hello"
|
||||
// }
|
||||
// ))
|
||||
// }
|
||||
rsx!(
|
||||
div {
|
||||
..attrs,
|
||||
"hello"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// let mut vdom = VirtualDom::new(app);
|
||||
// _ = vdom.rebuild();
|
||||
let mut vdom = VirtualDom::new(app);
|
||||
vdom.rebuild(&mut NoOpMutations);
|
||||
|
||||
// vdom.mark_dirty(ScopeId::ROOT);
|
||||
// assert_eq!(
|
||||
// vdom.render_immediate().santize().edits,
|
||||
// [
|
||||
// SetAttribute {
|
||||
// name: "b",
|
||||
// value: (&AttributeValue::Text("hello",)).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// SetAttribute {
|
||||
// name: "c",
|
||||
// value: (&AttributeValue::Text("hello",)).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// ]
|
||||
// );
|
||||
vdom.mark_dirty(ScopeId::ROOT);
|
||||
assert_eq!(
|
||||
vdom.render_immediate_to_vec().santize().edits,
|
||||
[
|
||||
SetAttribute {
|
||||
name: "b",
|
||||
value: (AttributeValue::Text("hello".into())),
|
||||
id: ElementId(1,),
|
||||
ns: None,
|
||||
},
|
||||
SetAttribute {
|
||||
name: "c",
|
||||
value: (AttributeValue::Text("hello".into())),
|
||||
id: ElementId(1,),
|
||||
ns: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
// vdom.mark_dirty(ScopeId::ROOT);
|
||||
// assert_eq!(
|
||||
// vdom.render_immediate().santize().edits,
|
||||
// [
|
||||
// SetAttribute {
|
||||
// name: "a",
|
||||
// value: (&AttributeValue::None).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// SetAttribute {
|
||||
// name: "b",
|
||||
// value: (&AttributeValue::None).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// SetAttribute {
|
||||
// name: "d",
|
||||
// value: (&AttributeValue::Text("hello",)).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// SetAttribute {
|
||||
// name: "e",
|
||||
// value: (&AttributeValue::Text("hello",)).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// ]
|
||||
// );
|
||||
vdom.mark_dirty(ScopeId::ROOT);
|
||||
assert_eq!(
|
||||
vdom.render_immediate_to_vec().santize().edits,
|
||||
[
|
||||
SetAttribute { name: "a", value: AttributeValue::None, id: ElementId(1,), ns: None },
|
||||
SetAttribute { name: "b", value: AttributeValue::None, id: ElementId(1,), ns: None },
|
||||
SetAttribute {
|
||||
name: "d",
|
||||
value: AttributeValue::Text("hello".into()),
|
||||
id: ElementId(1,),
|
||||
ns: None,
|
||||
},
|
||||
SetAttribute {
|
||||
name: "e",
|
||||
value: AttributeValue::Text("hello".into()),
|
||||
id: ElementId(1,),
|
||||
ns: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
// vdom.mark_dirty(ScopeId::ROOT);
|
||||
// assert_eq!(
|
||||
// vdom.render_immediate().santize().edits,
|
||||
// [
|
||||
// SetAttribute {
|
||||
// name: "c",
|
||||
// value: (&AttributeValue::None).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// SetAttribute {
|
||||
// name: "d",
|
||||
// value: (&AttributeValue::Text("world",)).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// SetAttribute {
|
||||
// name: "e",
|
||||
// value: (&AttributeValue::None).into(),
|
||||
// id: ElementId(1,),
|
||||
// ns: None,
|
||||
// },
|
||||
// ]
|
||||
// );
|
||||
vdom.mark_dirty(ScopeId::ROOT);
|
||||
assert_eq!(
|
||||
vdom.render_immediate_to_vec().santize().edits,
|
||||
[
|
||||
SetAttribute { name: "c", value: AttributeValue::None, id: ElementId(1,), ns: None },
|
||||
SetAttribute {
|
||||
name: "d",
|
||||
value: AttributeValue::Text("world".into()),
|
||||
id: ElementId(1,),
|
||||
ns: None,
|
||||
},
|
||||
SetAttribute { name: "e", value: AttributeValue::None, id: ElementId(1,), ns: None },
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ static CLICKS: Mutex<usize> = Mutex::new(0);
|
||||
|
||||
#[test]
|
||||
fn events_propagate() {
|
||||
set_event_converter(Box::new(dioxus_html::SerializedHtmlEventConverter));
|
||||
set_event_converter(Box::new(dioxus::html::SerializedHtmlEventConverter));
|
||||
|
||||
let mut dom = VirtualDom::new(app);
|
||||
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
//! Tests for the lifecycle of components.
|
||||
use dioxus::dioxus_core::{ElementId, Mutation::*};
|
||||
use dioxus::html::SerializedHtmlEventConverter;
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_html::SerializedHtmlEventConverter;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ async fn flushing() {
|
||||
fn app() -> Element {
|
||||
use_hook(|| {
|
||||
spawn(async move {
|
||||
for x in 0..10 {
|
||||
for _ in 0..10 {
|
||||
flush_sync().await;
|
||||
SEQUENCE.with(|s| s.borrow_mut().push(1));
|
||||
}
|
||||
@@ -103,7 +103,7 @@ async fn flushing() {
|
||||
|
||||
use_hook(|| {
|
||||
spawn(async move {
|
||||
for x in 0..10 {
|
||||
for _ in 0..10 {
|
||||
flush_sync().await;
|
||||
SEQUENCE.with(|s| s.borrow_mut().push(2));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user