From 22b1132340988e1adaea8602424ed563ba0be461 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sat, 6 Jul 2024 12:56:29 -0400 Subject: [PATCH] chore: clippy and clean up unused functions --- meta/src/body.rs | 11 ++++------- meta/src/html.rs | 22 ++++------------------ meta/src/lib.rs | 6 ++---- tachys/src/html/element/mod.rs | 21 ++++----------------- 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/meta/src/body.rs b/meta/src/body.rs index 6813ad838..f398d5d83 100644 --- a/meta/src/body.rs +++ b/meta/src/body.rs @@ -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 `` element from /// within the application. @@ -60,7 +58,6 @@ struct BodyViewState where At: Attribute, { - el: HtmlElement, attributes: At::State, } @@ -74,7 +71,7 @@ where let el = document().body().expect("there to be a 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::() { 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 element"); let attributes = self.attributes.hydrate::(&el); - BodyViewState { el, attributes } + BodyViewState { attributes } } } diff --git a/meta/src/html.rs b/meta/src/html.rs index 21ae55324..04dd78dfb 100644 --- a/meta/src/html.rs +++ b/meta/src/html.rs @@ -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 `` element from /// within the application. @@ -68,7 +55,6 @@ struct HtmlViewState where At: Attribute, { - 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::() { 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::(&el); - HtmlViewState { el, attributes } + HtmlViewState { attributes } } } diff --git a/meta/src/lib.rs b/meta/src/lib.rs index 098477692..07cb7edc4 100644 --- a/meta/src/lib.rs +++ b/meta/src/lib.rs @@ -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; diff --git a/tachys/src/html/element/mod.rs b/tachys/src/html/element/mod.rs index 1015f70f6..4f6ae6ac2 100644 --- a/tachys/src/html/element/mod.rs +++ b/tachys/src/html/element/mod.rs @@ -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(attribute: At, buf: &mut String) -> String -where - At: Attribute, - R: Renderer, -{ - attributes_to_html(std::iter::once(attribute), buf) -} - -pub fn attributes_to_html( - attributes: impl IntoIterator, - buf: &mut String, -) -> String +pub fn attributes_to_html(attr: At, buf: &mut String) -> String where At: Attribute, 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(' ');