Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): set end location for incomplete elements #9598

Merged
merged 1 commit into from Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/parser/html-parser.js
Expand Up @@ -279,7 +279,7 @@ export function parseHTML (html, options) {
) {
options.warn(
`tag <${stack[i].tag}> has no matching end tag.`,
{ start: stack[i].start }
{ start: stack[i].start, end: stack[i].end }
)
}
if (options.end) {
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/parser/index.js
Expand Up @@ -210,7 +210,7 @@ export function parse (
shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
shouldKeepComment: options.comments,
outputSourceRange: options.outputSourceRange,
start (tag, attrs, unary, start) {
start (tag, attrs, unary, start, end) {
// check namespace.
// inherit parent ns if there is one
const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag)
Expand All @@ -229,6 +229,7 @@ export function parse (
if (process.env.NODE_ENV !== 'production') {
if (options.outputSourceRange) {
element.start = start
element.end = end
element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
cumulated[attr.name] = attr
return cumulated
Expand Down
5 changes: 5 additions & 0 deletions test/unit/modules/compiler/compiler-options.spec.js
Expand Up @@ -140,6 +140,11 @@ describe('compile options', () => {
expect(compiled.errors[0].end).toBe(17)
expect(compiled.errors[1].start).toBe(18)
expect(compiled.errors[1].end).toBe(29)

compiled = compile('<div><span></div>', { outputSourceRange: true })
expect(compiled.errors.length).toBe(1)
expect(compiled.errors[0].start).toBe(5)
expect(compiled.errors[0].end).toBe(11)
})

it('should collect source range for binding keys', () => {
Expand Down