Skip to content

Commit f05a8d6

Browse files
authored
fix(compiler-core): do not increase newlines in InEntity state (#13362)
1 parent 762fae4 commit f05a8d6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/compiler-core/__tests__/parse.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,11 @@ describe('compiler: parse', () => {
22712271
expect(span.loc.start.offset).toBe(0)
22722272
expect(span.loc.end.offset).toBe(27)
22732273
})
2274+
2275+
test('correct loc when a line in attribute value ends with &', () => {
2276+
const [span] = baseParse(`<span v-if="foo &&\nbar"></span>`).children
2277+
expect(span.loc.end.line).toBe(2)
2278+
})
22742279
})
22752280

22762281
describe('decodeEntities option', () => {

packages/compiler-core/src/tokenizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ export default class Tokenizer {
929929
this.buffer = input
930930
while (this.index < this.buffer.length) {
931931
const c = this.buffer.charCodeAt(this.index)
932-
if (c === CharCodes.NewLine) {
932+
if (c === CharCodes.NewLine && this.state !== State.InEntity) {
933933
this.newlines.push(this.index)
934934
}
935935
switch (this.state) {

0 commit comments

Comments
 (0)