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

Lost slash in self-closing tag #4

Open
impworks opened this issue Sep 26, 2017 · 2 comments
Open

Lost slash in self-closing tag #4

impworks opened this issue Sep 26, 2017 · 2 comments

Comments

@impworks
Copy link

When using a self-closing tag in the included template, the slash is lost in the output, For example:

template.html:

<div>
    <router-view />
</div>

control.js:

import template from './template.html';

Result:

var template = "<div>\r\n    <router-view>\r\n</div>";
@bdadam
Copy link
Owner

bdadam commented Sep 26, 2017

This is because your example is not valid html. Custom tags cannot be self-closing, they always need a closing tag. A slash in the tag name is only allowed for void elements, which custom elements are not.
See: https://www.w3.org/TR/html/syntax.html#start-tags

@impworks Nevertheless thanks for reporting this, this is a quite common confusion.

@impworks
Copy link
Author

Thank you for the reply.
You are right - the spec says that all custom tags must be explicitly closed.

I found out that my issue can be fixed by using the keepClosingSlash option in HTML Minifier.
While the resulting code is technically incorrect, it does work in Chrome and is quite convenient to write for testing purposes.

Would be nice if HTML Minifier issued a warning though.

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

No branches or pull requests

2 participants