mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
chore: clippy and clean up unused functions
This commit is contained in:
parent
504c958001
commit
ccf6703274
4 changed files with 14 additions and 46 deletions
|
@ -1,8 +1,7 @@
|
|||
use crate::ServerMetaContext;
|
||||
use leptos::{
|
||||
attr::NextAttribute,
|
||||
component,
|
||||
html::{self, body, ElementExt},
|
||||
component, html,
|
||||
reactive_graph::owner::use_context,
|
||||
tachys::{
|
||||
dom::document,
|
||||
|
@ -16,7 +15,6 @@ use leptos::{
|
|||
},
|
||||
IntoView,
|
||||
};
|
||||
use web_sys::HtmlElement;
|
||||
|
||||
/// A component to set metadata on the document’s `<body>` element from
|
||||
/// within the application.
|
||||
|
@ -60,7 +58,6 @@ struct BodyViewState<At>
|
|||
where
|
||||
At: Attribute<Dom>,
|
||||
{
|
||||
el: HtmlElement,
|
||||
attributes: At::State,
|
||||
}
|
||||
|
||||
|
@ -74,7 +71,7 @@ where
|
|||
let el = document().body().expect("there to be a <body> element");
|
||||
let attributes = self.attributes.build(&el);
|
||||
|
||||
BodyViewState { el, attributes }
|
||||
BodyViewState { attributes }
|
||||
}
|
||||
|
||||
fn rebuild(self, state: &mut Self::State) {
|
||||
|
@ -128,7 +125,7 @@ where
|
|||
) {
|
||||
if let Some(meta) = use_context::<ServerMetaContext>() {
|
||||
let mut buf = String::new();
|
||||
_ = html::attribute_to_html(self.attributes, &mut buf);
|
||||
_ = html::attributes_to_html(self.attributes, &mut buf);
|
||||
if !buf.is_empty() {
|
||||
_ = meta.body.send(buf);
|
||||
}
|
||||
|
@ -143,7 +140,7 @@ where
|
|||
let el = document().body().expect("there to be a <body> element");
|
||||
let attributes = self.attributes.hydrate::<FROM_SERVER>(&el);
|
||||
|
||||
BodyViewState { el, attributes }
|
||||
BodyViewState { attributes }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,7 @@ use leptos::{
|
|||
reactive_graph::owner::use_context,
|
||||
tachys::{
|
||||
dom::document,
|
||||
html::{
|
||||
attribute::{
|
||||
self,
|
||||
any_attribute::{
|
||||
AnyAttribute, AnyAttributeState, IntoAnyAttribute,
|
||||
},
|
||||
Attribute,
|
||||
},
|
||||
class,
|
||||
},
|
||||
html::attribute::Attribute,
|
||||
hydration::Cursor,
|
||||
renderer::{dom::Dom, Renderer},
|
||||
view::{
|
||||
|
@ -22,12 +13,8 @@ use leptos::{
|
|||
RenderHtml,
|
||||
},
|
||||
},
|
||||
text_prop::TextProp,
|
||||
IntoView,
|
||||
};
|
||||
use or_poisoned::OrPoisoned;
|
||||
use std::mem;
|
||||
use web_sys::Element;
|
||||
|
||||
/// A component to set metadata on the document’s `<html>` element from
|
||||
/// within the application.
|
||||
|
@ -68,7 +55,6 @@ struct HtmlViewState<At>
|
|||
where
|
||||
At: Attribute<Dom>,
|
||||
{
|
||||
el: Element,
|
||||
attributes: At::State,
|
||||
}
|
||||
|
||||
|
@ -85,7 +71,7 @@ where
|
|||
|
||||
let attributes = self.attributes.build(&el);
|
||||
|
||||
HtmlViewState { el, attributes }
|
||||
HtmlViewState { attributes }
|
||||
}
|
||||
|
||||
fn rebuild(self, state: &mut Self::State) {
|
||||
|
@ -139,7 +125,7 @@ where
|
|||
) {
|
||||
if let Some(meta) = use_context::<ServerMetaContext>() {
|
||||
let mut buf = String::new();
|
||||
_ = html::attribute_to_html(self.attributes, &mut buf);
|
||||
_ = html::attributes_to_html(self.attributes, &mut buf);
|
||||
if !buf.is_empty() {
|
||||
_ = meta.html.send(buf);
|
||||
}
|
||||
|
@ -157,7 +143,7 @@ where
|
|||
|
||||
let attributes = self.attributes.hydrate::<FROM_SERVER>(&el);
|
||||
|
||||
HtmlViewState { el, attributes }
|
||||
HtmlViewState { attributes }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,13 +51,12 @@ use futures::{Stream, StreamExt};
|
|||
use leptos::{
|
||||
attr::NextAttribute,
|
||||
component,
|
||||
html::attributes_to_html,
|
||||
logging::debug_warn,
|
||||
reactive_graph::owner::{provide_context, use_context},
|
||||
tachys::{
|
||||
dom::document,
|
||||
html::{
|
||||
attribute::{any_attribute::AnyAttribute, Attribute},
|
||||
attribute::Attribute,
|
||||
element::{CreateElement, ElementType, HtmlElement},
|
||||
},
|
||||
hydration::Cursor,
|
||||
|
@ -70,13 +69,12 @@ use leptos::{
|
|||
IntoView,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use or_poisoned::OrPoisoned;
|
||||
use send_wrapper::SendWrapper;
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
sync::{
|
||||
mpsc::{channel, Receiver, Sender},
|
||||
Arc, RwLock,
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
use wasm_bindgen::JsCast;
|
||||
|
|
|
@ -278,7 +278,7 @@ where
|
|||
buf.push('<');
|
||||
buf.push_str(E::TAG);
|
||||
|
||||
let inner_html = attribute_to_html(self.attributes, buf);
|
||||
let inner_html = attributes_to_html(self.attributes, buf);
|
||||
|
||||
buf.push('>');
|
||||
|
||||
|
@ -316,7 +316,7 @@ where
|
|||
buf.push('<');
|
||||
buf.push_str(E::TAG);
|
||||
|
||||
let inner_html = attribute_to_html(self.attributes, &mut buf);
|
||||
let inner_html = attributes_to_html(self.attributes, &mut buf);
|
||||
|
||||
buf.push('>');
|
||||
buffer.push_sync(&buf);
|
||||
|
@ -386,18 +386,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn attribute_to_html<At, R>(attribute: At, buf: &mut String) -> String
|
||||
where
|
||||
At: Attribute<R>,
|
||||
R: Renderer,
|
||||
{
|
||||
attributes_to_html(std::iter::once(attribute), buf)
|
||||
}
|
||||
|
||||
pub fn attributes_to_html<At, R>(
|
||||
attributes: impl IntoIterator<Item = At>,
|
||||
buf: &mut String,
|
||||
) -> String
|
||||
pub fn attributes_to_html<At, R>(attr: At, buf: &mut String) -> String
|
||||
where
|
||||
At: Attribute<R>,
|
||||
R: Renderer,
|
||||
|
@ -416,9 +405,7 @@ where
|
|||
let mut inner_html = String::new();
|
||||
|
||||
// inject regular attributes, and fill class and style
|
||||
for attr in attributes {
|
||||
attr.to_html(buf, &mut class, &mut style, &mut inner_html);
|
||||
}
|
||||
attr.to_html(buf, &mut class, &mut style, &mut inner_html);
|
||||
|
||||
if !class.is_empty() {
|
||||
buf.push(' ');
|
||||
|
|
Loading…
Reference in a new issue