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

Add support for <!> comment shorthand #1288

Closed
dummdidumm opened this issue Mar 5, 2024 · 2 comments · Fixed by #1358
Closed

Add support for <!> comment shorthand #1288

dummdidumm opened this issue Mar 5, 2024 · 2 comments · Fixed by #1358
Assignees
Labels
enhancement New feature or request

Comments

@dummdidumm
Copy link

Is your feature request related to a problem? Please describe.
The browser (jsdom, too) auto-repairs <!> tags to proper comments (e.g. <!---->). happy-dom does not do that and treats that character sequence as text. Frameworks like Svelte or Solid use this to their advantage to safe a bit of space when generating the template strings from which the component DOM tree is constructed.

Describe the solution you'd like
Add support for the shorthand, so that the following works as expected:

/**
 * @vitest-environment happy-dom
 */
import { test } from "vitest";

test("can render", () => {
  const root = document.createElement("div");
  root.innerHTML = "x<!>y";
  document.body.append(root);
  console.log(document.body.innerHTML);
  // should print <div>x<!---->y</div> , currently prints <div>x<!>y</div>
});

Describe alternatives you've considered
None

@dummdidumm dummdidumm added the enhancement New feature or request label Mar 5, 2024
@capricorn86 capricorn86 self-assigned this Mar 24, 2024
@capricorn86 capricorn86 linked a pull request Mar 24, 2024 that will close this issue
capricorn86 added a commit that referenced this issue Mar 24, 2024
…t-shorthand

fix: [#1288] Adds support for parsing shorthand comments
@capricorn86
Copy link
Owner

Thank you for reporting @dummdidumm! 🙂

I have made a fix now:
https://github.com/capricorn86/happy-dom/releases/tag/v14.3.6

@dummdidumm
Copy link
Author

Thank you!

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

Successfully merging a pull request may close this issue.

2 participants