Fix hydration of link element (#4561)
* Fix hydration of link element * revert some logging changes * clean up fullstack history provider * fix router tests * fix document context type
This commit is contained in:
1 parent
6cd4453662
commit
021565c171
12 files changed
+141
-109
No files matched your search
@@ -4,17 +4,11 @@
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
#[cfg(all(feature = "web", feature = "document"))]
|
||||
mod web;
|
||||
|
||||
mod error;
|
||||
#[doc(hidden)]
|
||||
pub mod mock_client;
|
||||
|
||||
#[cfg(all(feature = "web", feature = "document"))]
|
||||
pub use web::FullstackWebDocument;
|
||||
|
||||
pub use dioxus_fullstack_hooks::history::FullstackHistory;
|
||||
pub use dioxus_fullstack_hooks::history::provide_fullstack_history_context;
|
||||
|
||||
pub use crate::error::{ServerFnError, ServerFnResult};
|
||||
#[doc(inline)]
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
//! On the client, we use the [`WebDocument`] implementation to render the head for any elements that were not rendered on the server.
|
||||
|
||||
use dioxus_document::*;
|
||||
use dioxus_web::WebDocument;
|
||||
|
||||
fn head_element_written_on_server() -> bool {
|
||||
dioxus_fullstack_protocol::head_element_hydration_entry()
|
||||
.get()
|
||||
.ok()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// A document provider for fullstack web clients
|
||||
#[derive(Clone)]
|
||||
pub struct FullstackWebDocument;
|
||||
|
||||
impl Document for FullstackWebDocument {
|
||||
fn eval(&self, js: String) -> Eval {
|
||||
WebDocument.eval(js)
|
||||
}
|
||||
|
||||
/// Set the title of the document
|
||||
fn set_title(&self, title: String) {
|
||||
WebDocument.set_title(title);
|
||||
}
|
||||
|
||||
/// Create a new meta tag in the head
|
||||
fn create_meta(&self, props: MetaProps) {
|
||||
WebDocument.create_meta(props);
|
||||
}
|
||||
|
||||
/// Create a new script tag in the head
|
||||
fn create_script(&self, props: ScriptProps) {
|
||||
WebDocument.create_script(props);
|
||||
}
|
||||
|
||||
/// Create a new style tag in the head
|
||||
fn create_style(&self, props: StyleProps) {
|
||||
WebDocument.create_style(props);
|
||||
}
|
||||
|
||||
/// Create a new link tag in the head
|
||||
fn create_link(&self, props: LinkProps) {
|
||||
WebDocument.create_link(props);
|
||||
}
|
||||
|
||||
fn create_head_component(&self) -> bool {
|
||||
!head_element_written_on_server()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user