Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/compiler-core/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,16 @@ describe('compiler: parse', () => {
baseParse(`<Foo>`, { parseMode: 'sfc', onError() {} })
expect(() => baseParse(`{ foo }`)).not.toThrow()
})

test('correct loc when the closing > is foarmatted', () => {
const [span] = baseParse(`<span></span

>`).children

expect(span.loc.source).toBe('<span></span\n \n >')
expect(span.loc.start.offset).toBe(0)
expect(span.loc.end.offset).toBe(27)
})
})

describe('decodeEntities option', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-core/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ const tokenizer = new Tokenizer(stack, {
},

onclosetag(start, end) {
const name = getSlice(start, end)
// trimming end because the tag can get formatted with newlines
const name = getSlice(start, end).trimEnd()
if (!currentOptions.isVoidTag(name)) {
let found = false
for (let i = 0; i < stack.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ export default class Tokenizer {
}
}
private stateInClosingTagName(c: number): void {
if (c === CharCodes.Gt || isWhitespace(c)) {
if (c === CharCodes.Gt) {
this.cbs.onclosetag(this.sectionStart, this.index)
this.sectionStart = -1
this.state = State.AfterClosingTagName
Expand Down