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

Line numbers for errors in the html parser #6338

Open
yacinehmito opened this issue Aug 10, 2017 · 3 comments
Open

Line numbers for errors in the html parser #6338

yacinehmito opened this issue Aug 10, 2017 · 3 comments

Comments

@yacinehmito
Copy link

What problem does this feature solve?

Errors raised by the html parser (options.warn in the code) don't register the location of the error.

With the location it will be much easier to debug.

For example if I forget to close an HTML tag, the compiler will complain and tell me the name of the tag. However I will have no idea where the opening tag is located. For moderately big files it's quite impractical.

What does the proposed API look like?

In parseHTML we could add a property in options that will include the line at which the HTML is included in the .vue file. We can use this to offset the location before printing it.

As for getting the locations themselves I have no idea how to proceed. If someone can give me some pointers I may submit a pull request.

@resolritter
Copy link

resolritter commented Aug 10, 2017

Is this what we should be looking at in relation to this issue?

https://github.com/vuejs/vue/blob/dev/src/compiler/parser/html-parser.js#L299


Well, there's also this one:

https://github.com/vuejs/vue/blob/dev/src/compiler/parser/html-parser.js#L188

It's location is self-explanatory.

@yacinehmito
Copy link
Author

Yes, these are definitely the warnings I am referring to.

@bastiW
Copy link

bastiW commented Mar 2, 2018

+1 for this. Right jumped into vue and that would realy help to debug the html code

This request is related to this pr: #7127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants