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

Self-closing /> is invalid syntax on non-void HTML elements #6

Closed
phoenix-ru opened this issue Oct 4, 2023 · 2 comments
Closed

Self-closing /> is invalid syntax on non-void HTML elements #6

phoenix-ru opened this issue Oct 4, 2023 · 2 comments

Comments

@phoenix-ru
Copy link
Owner

phoenix-ru commented Oct 4, 2023

Problem

The official Vue parser allows self-closing any HTML, but this is not valid by the spec. For example, this:

<template>
  <slot />
  <div class="bad" />
</template>

Using Nu HTML Checker by W3 results in a clear error:
image

The same happens when parsing with swc_html_parser. The error is being reported and the tag is not being closed:

InvalidHtml(NonVoidHtmlElementStartTagWithTrailingSolidus) <slot />

In addition, this also messes up the DOM Tree stack, which is the actual problem here.

Possible solution

All NonVoidHtmlElementStartTagWithTrailingSolidus should be considered a hard error.

Nice-to-have

It would also be nice to do RegEx search-replace as a utility in fervid.
Another option is to parse the HTML and only apply this fix to where the NonVoidHtmlElementStartTagWithTrailingSolidus problem is encountered.

@phoenix-ru
Copy link
Owner Author

Raised concerns with SWC project in hopes to get a configuration flag for it
swc-project/swc#8424

@phoenix-ru
Copy link
Owner Author

Closed in SWC via swc-project/swc#8460

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

1 participant