From 39634d5b1495a080cbca398259d6bff7ee49e671 Mon Sep 17 00:00:00 2001 From: Elijah Mooring Date: Thu, 4 Aug 2022 20:13:26 -0500 Subject: [PATCH] fix: closing brackets being included --- compiler/attribute.test.ts | 7 +++++++ compiler/attribute.ts | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/attribute.test.ts b/compiler/attribute.test.ts index 30047d5..5ecac25 100644 --- a/compiler/attribute.test.ts +++ b/compiler/attribute.test.ts @@ -64,3 +64,10 @@ Deno.test({ ) }, }) + +Deno.test({ + name: '[attribute] embedded expressions should work', + fn() { + test(`{hello} man that />`, { length: 7, jsString: '`${hello}`' }) + }, +}) diff --git a/compiler/attribute.ts b/compiler/attribute.ts index f563df1..f0e5d45 100644 --- a/compiler/attribute.ts +++ b/compiler/attribute.ts @@ -205,7 +205,9 @@ export function attributeToTemplateLiteral(string: string): AttributeToTemplateL // Ok, now that we are done with the loop and we have consumed all that we would need to, we need to finish off the // JS template literal we have started. - if (topLevelStrategy === 'quoted') jsString += '`' + // But we don't want to any closing brace to the {expression} attributes. That closing bracket was already added when the + // expression finished + if (topLevelStrategy === 'quoted' || topLevelStrategy === 'none') jsString += '`' else jsString += '}`' return { originalAttributeLength: consumed, jsString }