mdn / dom-examples

Code examples that accompany various MDN DOM and Web API documentation pages
https://developer.mozilla.org/en-US/docs/Web/API
Creative Commons Zero v1.0 Universal
3.46k stars 1.8k forks source link

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

Closed bsmth closed 7 months ago

bsmth commented 7 months ago

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

Changes:

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

pepelsbey commented 7 months ago

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 commented 7 months ago

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 https://github.com/mdn/dom-examples/pull/268/commits/378f31b0a4a6c8b26e61c9ee6c044d1fb51e2e66

Going to merge shortly, ty!