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 lint rule to ensure <img> is self closing #240

Open
khiga8 opened this issue Mar 22, 2022 · 3 comments
Open

Add lint rule to ensure <img> is self closing #240

khiga8 opened this issue Mar 22, 2022 · 3 comments

Comments

@khiga8
Copy link
Contributor

khiga8 commented Mar 22, 2022

When <img> is does not have self closing slash like <img />, vercel deploys broke completely.

<img > is considered valid HTML as it is a void element, but for some reason <img > breaks vercel deploys.

Apparently <img> is not valid in XHTML or XML and needs to be <img /> so maybe XHTML or XML is being used under the hood somewhere? Not sure

We should investigate why this breaks and/or add a lint rule so we catch this at the linting stage and prevent future headaches.

@yaili
Copy link
Member

yaili commented Mar 22, 2022

@khiga8 does this happen in the design docs only, or across all primer.style docs?

@khiga8
Copy link
Contributor Author

khiga8 commented Mar 22, 2022

This was specifically observed in this design repo in a .mdx file. Here's a related commit that fixed it.

@koddsson
Copy link

JSX isn't HTML and has its own semantics. One of the ways it differs from HTML is that all elements need to close, either by self-closing or with a closing element.

<img> is invalid in JSX but is how we define images in HTML.

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

5 participants
@yaili @koddsson @khiga8 and others