Skip to content

Commit

Permalink
perf: more mustache tag check optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlyu123 committed Nov 24, 2023
1 parent 79aa1ed commit 3aa38bc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ export function handleAttribute(
return;
}

const lastCharIndex = attrVal.end - 1;
const hasBrackets =
str.original.lastIndexOf('}', attrVal.end) === attrVal.end - 1 ||
str.original.lastIndexOf('}"', attrVal.end) === attrVal.end - 1 ||
str.original.lastIndexOf("}'", attrVal.end) === attrVal.end - 1;
str.original[lastCharIndex] === '}' ||
((str.original[lastCharIndex] === '"' || str.original[lastCharIndex] === "'") &&
str.original[lastCharIndex - 1] === '}');

const needsNumberConversion =
!hasBrackets &&
parent.type === 'Element' &&
Expand Down

0 comments on commit 3aa38bc

Please sign in to comment.