From 74e51b7e0d924c24dbd3870aca1bcff990494f7d Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 31 Jul 2024 00:34:27 +0200 Subject: [PATCH] Fix hot reloading spreads (#2750) --- packages/rsx/src/element.rs | 4 ++-- packages/rsx/tests/hotreload_pattern.rs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/rsx/src/element.rs b/packages/rsx/src/element.rs index 07cdf09aa..06993af44 100644 --- a/packages/rsx/src/element.rs +++ b/packages/rsx/src/element.rs @@ -76,7 +76,7 @@ impl Parse for Element { // Assemble the new element from the contents of the block let mut element = Element { brace, - name, + name: name.clone(), raw_attributes: block.attributes, children: block.children, diagnostics: block.diagnostics, @@ -98,7 +98,7 @@ impl Parse for Element { value: AttributeValue::AttrExpr(PartialExpr::from_expr(&spread.expr)), comma: spread.comma, dyn_idx: spread.dyn_idx.clone(), - el_name: None, + el_name: Some(name.clone()), }); } diff --git a/packages/rsx/tests/hotreload_pattern.rs b/packages/rsx/tests/hotreload_pattern.rs index 3b9c6e94c..1ad9a3a15 100644 --- a/packages/rsx/tests/hotreload_pattern.rs +++ b/packages/rsx/tests/hotreload_pattern.rs @@ -1125,3 +1125,25 @@ fn valid_fill_empty() { assert!(valid); } + +// We should be able to hot reload spreads +#[test] +fn valid_spread() { + let valid = can_hotreload( + quote! { + div { + ..spread + } + }, + quote! { + div { + "hello world" + } + h1 { + ..spread + } + }, + ); + + assert!(valid); +}