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

lang="" on a html tag produces "VueCompilerError: Invalid end tag." #2566

Closed
xPaw opened this issue Nov 6, 2020 · 7 comments · Fixed by #2569
Closed

lang="" on a html tag produces "VueCompilerError: Invalid end tag." #2566

xPaw opened this issue Nov 6, 2020 · 7 comments · Fixed by #2569
Labels
has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working scope: sfc

Comments

@xPaw
Copy link

xPaw commented Nov 6, 2020

Version

16.0.0-rc.0

Reproduction link

https://github.com/xPaw/vue-loader-lang-bug

Steps to reproduce

Clone my repro project, yarn and yarn webpack.

Template:

<template>
	<div lang="">
		<div></div>
	</div>
</template>

What is expected?

Compilation succeeds

What is actually happening?

ERROR in ./src/test.vue
Module Error (from ./node_modules/vue-loader/dist/index.js):

VueCompilerError: Invalid end tag.
at src\test.vue:4:2
2  |    <div lang="">
3  |            <div></div>
4  |    </div>
   |      ^
5  |  </template>

 @ ./src/index.js 1:0-21

Removing lang="" attribute fixes this.


vuejs/vue-loader#1726 was closed as not being able to repro, but it still won't compile.

@haoqunjiang
Copy link
Member

Sorry for closing the other issue too soon. As the original reproduction was too big, I tried to reproduce with a hello-world project. When I tried div lang="" on that project, it worked.

It is because I missed a critical part of the bug - besides the lang="" attribute, the content of the element needs contain a closing tag like </div> causing the parser to clear the stack too early.

@haoqunjiang
Copy link
Member

@haoqunjiang haoqunjiang transferred this issue from vuejs/vue-loader Nov 6, 2020
@xPaw
Copy link
Author

xPaw commented Nov 6, 2020

Right, makes sense that is in the compiler, I didn't know where exactly the bug was, because the vue ast thing worked fine.

@haoqunjiang
Copy link
Member

haoqunjiang commented Nov 6, 2020

A temporary workaround: use :lang="''", because the SFC parser only checks for the static lang attribute, so a dynamic one can circumvent this check.

@asoglovo
Copy link

asoglovo commented Nov 9, 2020

For a case like this where you add attributes to native elements, wouldn't the data-* html attributes be a better fit?

@xPaw
Copy link
Author

xPaw commented Nov 9, 2020

@asoglovo
Copy link

asoglovo commented Nov 9, 2020

Oh, didn't know that :) Thanks for the clarification

@posva posva added the has PR A pull request has already been submitted to solve the issue label Nov 18, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working scope: sfc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants