diff --git a/TODO.md b/TODO.md index 9ad3781b0..fdfb9bf58 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,6 @@ - Start consolidating components + cleaning them up - ability to detach instances + - detach lightning icon + + - ability to parse comments diff --git a/libs/core/src/proto/ast_mutate/set_text_node_value.rs b/libs/core/src/proto/ast_mutate/set_text_node_value.rs index 813942ef3..a31dee829 100644 --- a/libs/core/src/proto/ast_mutate/set_text_node_value.rs +++ b/libs/core/src/proto/ast_mutate/set_text_node_value.rs @@ -14,7 +14,7 @@ impl MutableVisitor<()> for EditContext { return VisitorResult::Continue; } - expr.value = self.mutation.value.to_string(); + expr.value = self.mutation.value.to_string().replace("\"", "\\\""); self.add_change( mutation_result::Inner::ExpressionUpdated(ExpressionUpdated { diff --git a/libs/core/src/proto/ast_mutate/test.rs b/libs/core/src/proto/ast_mutate/test.rs index 4964da88a..8722dc0b4 100644 --- a/libs/core/src/proto/ast_mutate/test.rs +++ b/libs/core/src/proto/ast_mutate/test.rs @@ -1765,6 +1765,27 @@ case! { )] } +case! { + can_use_quotes_with_text_node_value, + [ + ( + "/entry.pc", r#" + text "a" + "# + ) + ], + + mutation::Inner::SetTextNodeValue(SetTextNodeValue { + text_node_id: "80f4925f-1".to_string(), + value: "b\"c\"".to_string() + }).get_outer(), + [( + "/entry.pc", r#" + text "b\"c\"" + "# + )] +} + case! { can_change_the_id_of_an_element, [ diff --git a/libs/parser/src/pc/tests/parser.rs b/libs/parser/src/pc/tests/parser.rs index 9f317cf92..35a2d16eb 100644 --- a/libs/parser/src/pc/tests/parser.rs +++ b/libs/parser/src/pc/tests/parser.rs @@ -204,6 +204,17 @@ add_case! { "# } +add_case! { + can_parse_a_string_with_quotes, + r#" + component A { + render div { + text "abc \"def\"" + } + } + "# +} + add_case! { can_parse_attributes, r#"