]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): do not increase newlines in `InEntity` state (#13362)
author山吹色御守 <85992002+KazariEX@users.noreply.github.com>
Thu, 5 Jun 2025 01:39:05 +0000 (18:39 -0700)
committerGitHub <noreply@github.com>
Thu, 5 Jun 2025 01:39:05 +0000 (09:39 +0800)
packages/compiler-core/__tests__/parse.spec.ts
packages/compiler-core/src/tokenizer.ts

index 4e5a96165118ce5a001329df595722bb9687a79a..cdc2b09fd48d12d6ba9c7a91e96fb688efbff787 100644 (file)
@@ -2271,6 +2271,11 @@ describe('compiler: parse', () => {
       expect(span.loc.start.offset).toBe(0)
       expect(span.loc.end.offset).toBe(27)
     })
+
+    test('correct loc when a line in attribute value ends with &', () => {
+      const [span] = baseParse(`<span v-if="foo &&\nbar"></span>`).children
+      expect(span.loc.end.line).toBe(2)
+    })
   })
 
   describe('decodeEntities option', () => {
index 329e8b481814329442586bec16aa0ad45e05eeb9..b8a74790259ec9aed4ca74a09905ce38e602a271 100644 (file)
@@ -929,7 +929,7 @@ export default class Tokenizer {
     this.buffer = input
     while (this.index < this.buffer.length) {
       const c = this.buffer.charCodeAt(this.index)
-      if (c === CharCodes.NewLine) {
+      if (c === CharCodes.NewLine && this.state !== State.InEntity) {
         this.newlines.push(this.index)
       }
       switch (this.state) {