Skip to content

Commit badd577

Browse files
committed
refactor(language-core): simplify calculation of full interpolation content
1 parent 2abec30 commit badd577

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

packages/language-core/lib/codegen/template/templateChild.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,16 @@ function getVIfNode(node: CompilerDOM.ElementNode) {
206206
}
207207

208208
export function parseInterpolationNode(node: CompilerDOM.InterpolationNode, template: string) {
209-
let content = node.content.loc.source;
210209
let start = node.content.loc.start.offset;
211-
let leftCharacter: string;
212-
let rightCharacter: string;
210+
let end = node.content.loc.end.offset;
213211

214212
// fix https://github.com/vuejs/language-tools/issues/1787
215-
while ((leftCharacter = template.slice(start - 1, start)).trim() === '' && leftCharacter.length) {
213+
while (template[start - 1]?.trim() === '') {
216214
start--;
217-
content = leftCharacter + content;
218215
}
219-
while (
220-
(rightCharacter = template.slice(start + content.length, start + content.length + 1)).trim() === ''
221-
&& rightCharacter.length
222-
) {
223-
content = content + rightCharacter;
216+
while (template[end]?.trim() === '') {
217+
end++;
224218
}
225219

226-
return [
227-
content,
228-
start,
229-
] as const;
220+
return [template.slice(start, end), start] as const;
230221
}

0 commit comments

Comments
 (0)