Skip to content

Commit

Permalink
Merge branch 'leptos-rs:main' into book-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
diversable authored Nov 22, 2023
2 parents f71d08f + 061213c commit 87c3b69
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/portal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ console_error_panic_hook = "0.1.7"
[dev-dependencies]
wasm-bindgen-test = "0.3.0"
wasm-bindgen = "0.2"
web-sys = "0.3"
web-sys = "0.3"
gloo-timers = { version = "0.3", features = ["futures"] }
8 changes: 6 additions & 2 deletions examples/portal/tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ use leptos::*;
use portal::App;
use web_sys::HtmlButtonElement;

async fn next_tick() {
gloo_timers::future::TimeoutFuture::new(25).await;
}

#[wasm_bindgen_test]
fn portal() {
async fn portal() {
let document = leptos::document();
let body = document.body().unwrap();

Expand All @@ -24,7 +28,7 @@ fn portal() {

show_button.click();

// next_tick().await;
next_tick().await;

// check HTML
assert_eq!(
Expand Down
6 changes: 3 additions & 3 deletions examples/session_auth_axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.4", features = ["fs"], optional = true }
tokio = { version = "1.22.0", features = ["full"], optional = true }
http = { version = "0.2.8" }
sqlx = { version = "0.6.2", features = [
sqlx = { version = "0.7.2", features = [
"runtime-tokio-rustls",
"sqlite",
], optional = true }
thiserror = "1.0.38"
wasm-bindgen = "0.2"
axum_session_auth = { version = "0.2.1", features = [
axum_session_auth = { version = "0.9.0", features = [
"sqlite-rustls",
], optional = true }
axum_session = { version = "0.2.3", features = [
axum_session = { version = "0.9.0", features = [
"sqlite-rustls",
], optional = true }
bcrypt = { version = "0.14", optional = true }
Expand Down
Binary file modified examples/session_auth_axum/Todos.db
Binary file not shown.
3 changes: 1 addition & 2 deletions examples/session_auth_axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ if #[cfg(feature = "ssr")] {
// Auth section
let session_config = SessionConfig::default().with_table_name("axum_sessions");
let auth_config = AuthConfig::<i64>::default();
let session_store = SessionStore::<SessionSqlitePool>::new(Some(pool.clone().into()), session_config);
session_store.initiate().await.unwrap();
let session_store = SessionStore::<SessionSqlitePool>::new(Some(pool.clone().into()), session_config).await.unwrap();

sqlx::migrate!()
.run(&pool)
Expand Down
39 changes: 36 additions & 3 deletions leptos_dom/src/macro_helpers/into_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,41 @@ attr_signal_type_optional!(MaybeProp<T>);
#[cfg(all(target_arch = "wasm32", feature = "web"))]
#[doc(hidden)]
#[inline(never)]
#[track_caller]
pub fn attribute_helper(
el: &web_sys::Element,
name: Oco<'static, str>,
value: Attribute,
) {
#[cfg(debug_assertions)]
let called_at = std::panic::Location::caller();
use leptos_reactive::create_render_effect;
match value {
Attribute::Fn(f) => {
let el = el.clone();
create_render_effect(move |old| {
let new = f();
if old.as_ref() != Some(&new) {
attribute_expression(&el, &name, new.clone(), true);
attribute_expression(
&el,
&name,
new.clone(),
true,
#[cfg(debug_assertions)]
called_at,
);
}
new
});
}
_ => attribute_expression(el, &name, value, false),
_ => attribute_expression(
el,
&name,
value,
false,
#[cfg(debug_assertions)]
called_at,
),
};
}

Expand All @@ -414,6 +431,7 @@ pub(crate) fn attribute_expression(
attr_name: &str,
value: Attribute,
force: bool,
#[cfg(debug_assertions)] called_at: &'static std::panic::Location<'static>,
) {
use crate::HydrationCtx;

Expand Down Expand Up @@ -452,10 +470,25 @@ pub(crate) fn attribute_expression(
}
Attribute::Fn(f) => {
let mut v = f();
crate::debug_warn!(
"At {called_at}, you are providing a dynamic attribute \
with a nested function. For example, you might have a \
closure that returns another function instead of a \
value. This creates some added overhead. If possible, \
you should instead provide a function that returns a \
value instead.",
);
while let Attribute::Fn(f) = v {
v = f();
}
attribute_expression(el, attr_name, v, force);
attribute_expression(
el,
attr_name,
v,
force,
#[cfg(debug_assertions)]
called_at,
);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions leptos_reactive/src/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl Trigger {
let diagnostics = diagnostics!(self);

with_runtime(|runtime| {
runtime.update_if_necessary(self.id);
self.id.subscribe(runtime, diagnostics);
})
.is_ok()
Expand Down

0 comments on commit 87c3b69

Please sign in to comment.