Skip to content

Commit

Permalink
Prevent binding from panicking when not in wasm (#278)
Browse files Browse the repository at this point in the history
* Prevent binding from panicking when not in wasm

* Fix cfg attributes
  • Loading branch information
Zoey authored Oct 15, 2021
1 parent a6baf3d commit 21509aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/sycamore-macro/src/template/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ impl ToTokens for Attribute {
tokens.extend(quote_spanned! { expr_span=> {
let signal: ::sycamore::reactive::Signal<#value_ty> = #expr;

#[cfg(target_arch = "wasm32")]
::sycamore::reactive::create_effect({
let signal = ::std::clone::Clone::clone(&signal);
let __el = ::std::clone::Clone::clone(&__el);
Expand Down
12 changes: 12 additions & 0 deletions packages/sycamore/tests/ssr/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,15 @@ fn indexed() {
let actual = sycamore::render_to_string(|| node.clone());
assert_eq!(actual, "<ul><li>2</li><li>3</li></ul>");
}

#[test]
fn bind() {
let signal = Signal::new(String::new());

let node = template! {
input(bind:value=signal)
};

let actual = sycamore::render_to_string(|| node);
assert_eq!(actual, "<input/>");
}

0 comments on commit 21509aa

Please sign in to comment.