Skip to content

Commit 675bfc4

Browse files
authored
perf: more mustache tag check optimization (#2215)
1 parent 79aa1ed commit 675bfc4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ export function handleAttribute(
171171
return;
172172
}
173173

174+
const lastCharIndex = attrVal.end - 1;
174175
const hasBrackets =
175-
str.original.lastIndexOf('}', attrVal.end) === attrVal.end - 1 ||
176-
str.original.lastIndexOf('}"', attrVal.end) === attrVal.end - 1 ||
177-
str.original.lastIndexOf("}'", attrVal.end) === attrVal.end - 1;
176+
str.original[lastCharIndex] === '}' ||
177+
((str.original[lastCharIndex] === '"' || str.original[lastCharIndex] === "'") &&
178+
str.original[lastCharIndex - 1] === '}');
179+
178180
const needsNumberConversion =
179181
!hasBrackets &&
180182
parent.type === 'Element' &&

0 commit comments

Comments
 (0)