Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/rsx/src/template_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ impl TemplateBody {

// Assign paths to all nodes in the template
body.assign_paths_inner(&nodes);
body.validate_key();

// And then save the roots
body.roots = nodes;

// Finally, validate the key
body.validate_key();

body
}

Expand Down
26 changes: 26 additions & 0 deletions packages/rsx/tests/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,29 @@ fn complex_kitchen_sink() {

let _cb: CallBody = syn::parse2(item).unwrap();
}

#[test]
fn key_must_be_formatted() {
let item = quote::quote! {
div {
key: value
}
};

let parsed = syn::parse2::<CallBody>(item).unwrap();
println!("{:?}", parsed.body.diagnostics);
assert!(!parsed.body.diagnostics.is_empty());
}

#[test]
fn key_cannot_be_static() {
let item = quote::quote! {
div {
key: "hello world"
}
};

let parsed = syn::parse2::<CallBody>(item).unwrap();
println!("{:?}", parsed.body.diagnostics);
assert!(!parsed.body.diagnostics.is_empty());
}
Loading