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

fix(html): Make script elements children of head or body elements #268

Merged
merged 3 commits into from Mar 22, 2024

Conversation

bsmth
Copy link
Member

@bsmth bsmth commented Mar 22, 2024

This PR fixes HTML validation errors relating to where the script element is permitted.

Changes:

  • Prettier formatting in parallel in changed files
  • <script> elements moved inside <head> or <body>

Additions:

There are two html-validate violations for the element-permitted-content rule left over after this PR:

html-validate ./**/*.html | grep -B 2 element-permitted-content
# dom-examples/popover-api/toggle-help-ui/index.html
#  24:6   error  <button> is missing recommended "type" attribute     no-implicit-button-type
#  37:10  error  <hr> element is not permitted as content under <ul>  element-permitted-content
#
# dom-examples/shadow-dom/shadowrootmode/scoping.html
#  16:8  error  <style> element is not permitted as content under <article>  element-permitted-content

How to review this PR

To ignore whitespace-only changes, view files using the following view:

https://github.com/mdn/dom-examples/pull/268/files?diff=split&w=1

Fixes #267

@bsmth bsmth requested a review from a team as a code owner March 22, 2024 12:52
@bsmth bsmth requested review from pepelsbey and removed request for a team March 22, 2024 12:52
Copy link
Contributor

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we’re at it, I’d suggest replacing ancient doctypes with modern ones. Fortunately, they’re identical from the browser parsers’ perspective. Otherwise, LGTM :) Thanks!

insert-adjacent/insertAdjacentText.html Outdated Show resolved Hide resolved
matchmedia/index.html Outdated Show resolved Hide resolved
@pepelsbey
Copy link
Contributor

pepelsbey commented Mar 22, 2024

Oh, BTW, https://html-validate.org/ is not an official validator for the HTML spec. They use their own set of rules, parser, etc. I’d suggest using https://validator.w3.org/ and packages based on it. For example, I use w3c-html-validator. It’s not “offline”, but it uses the W3C’s API for checking the document.

bsmth and others added 2 commits March 22, 2024 16:43
@bsmth
Copy link
Member Author

bsmth commented Mar 22, 2024

Oh, BTW, https://html-validate.org/ is not an official validator for the HTML spec. They use their own set of rules, parser, etc. I’d suggest using https://validator.w3.org/ and packages based on it. For example, I use w3c-html-validator. It’s not “offline”, but it uses the W3C’s API for checking the document.

Good call, removed in 378f31b

Going to merge shortly, ty!

@bsmth bsmth merged commit 6d7115e into mdn:main Mar 22, 2024
3 checks passed
@bsmth bsmth deleted the 267-script-elements branch March 22, 2024 16:07
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

Successfully merging this pull request may close these issues.

Code examples have stray <script> tags
2 participants