mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
This commit is contained in:
parent
998165148b
commit
2b8e987cb8
3 changed files with 26 additions and 14 deletions
|
@ -56,6 +56,7 @@ hydration = [
|
|||
"reactive_graph/hydration",
|
||||
"leptos_server/hydration",
|
||||
"hydration_context/browser",
|
||||
"leptos_dom/hydration"
|
||||
]
|
||||
csr = ["leptos_macro/csr", "reactive_graph/effects"]
|
||||
hydrate = [
|
||||
|
|
|
@ -30,6 +30,7 @@ features = ["Location"]
|
|||
default = []
|
||||
tracing = ["dep:tracing"]
|
||||
trace-component-props = ["dep:serde", "dep:serde_json"]
|
||||
hydration = ["reactive_graph/hydration"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustdoc-args = ["--generate-link-to-definition"]
|
||||
|
|
|
@ -64,10 +64,9 @@ pub fn location() -> web_sys::Location {
|
|||
/// Current [`window.location.hash`](https://developer.mozilla.org/en-US/docs/Web/API/Window/location)
|
||||
/// without the beginning #.
|
||||
pub fn location_hash() -> Option<String> {
|
||||
// TODO use shared context for is_server
|
||||
/*if is_server() {
|
||||
if is_server() {
|
||||
None
|
||||
} else {*/
|
||||
} else {
|
||||
location()
|
||||
.hash()
|
||||
.ok()
|
||||
|
@ -75,7 +74,7 @@ pub fn location_hash() -> Option<String> {
|
|||
Some('#') => hash[1..].to_string(),
|
||||
_ => hash,
|
||||
})
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
/// Current [`window.location.pathname`](https://developer.mozilla.org/en-US/docs/Web/API/Window/location).
|
||||
|
@ -475,9 +474,7 @@ pub fn window_event_listener_untyped(
|
|||
cb(e);
|
||||
};
|
||||
|
||||
// TODO use shared context for is_server
|
||||
if true {
|
||||
// !is_server() {
|
||||
if !is_server() {
|
||||
#[inline(never)]
|
||||
fn wel(
|
||||
cb: Box<dyn FnMut(web_sys::Event)>,
|
||||
|
@ -550,3 +547,16 @@ impl WindowListenerHandle {
|
|||
(self.0)()
|
||||
}
|
||||
}
|
||||
|
||||
fn is_server() -> bool {
|
||||
#[cfg(feature = "hydration")]
|
||||
{
|
||||
Owner::current_shared_context()
|
||||
.map(|sc| !sc.is_browser())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
#[cfg(not(feature = "hydration"))]
|
||||
{
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue