Closed binyamin closed 2 years ago
Hi Binyamin! You’re right that the spec says that. However, that’s more of a section on how people should write HTML (sometimes the spec is a bit unclear about them).
There are different actual labels that browsers must support: https://encoding.spec.whatwg.org/#names-and-labels. utf8
is the shortest one of that group. See here for how those groups (and more) are supported:
This project in many places uses these “leniencies” in the HTML spec to create “parse errors” and other things that linters would warn about, while the HTML spec in other places defines exactly how those errors/warnings must be handled by browsers.
In this case,
utf8
: https://encoding.spec.whatwg.org/#concept-encoding-get.Closing as intentional, let me know if you have further questions!
@wooorm That makes sense. However, it seems only fair that "utf-8" should be preserved as is, at least via an option. It only adds one character, and it encourages conformant HTML.
Initial checklist
Affected packages and versions
rehype-minify-enumerated-attribute@4.1.0
Link to runnable example
No response
Steps to reproduce
Run the following code, modifying for your environment as necessary
Expected behavior
According to the WHATWG's HTML Living Standard, the charset attribute must be source). The W3 HTML validator accordingly produces errors.
(Therefore, expected behavior is that, when the charset attribute exists on a meta element, its value is either coerced to a valid value, or at least not coerced to "utf8" (no space).
Actual behavior
UTF-8
becomesutf8
, probably because it's the shortest string defined inschema.js
.Runtime
Deno
Package manager
No response
OS
Linux
Build and bundle tools
No response