Don't add ="" to custom boolean attributes
Categories
(Core :: DOM: Serializers, defect)
Tracking
()
People
(Reporter: chris.weaver, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: testcase)
Attachments
(1 file)
|
226 bytes,
text/html
|
Details |
Comment 5•23 years ago
|
||
Updated•19 years ago
|
Comment 6•3 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Comment 7•3 years ago
|
||
I think that it's no problem to add ="", but I don't find any standards about serialization of boolean attributes. Anyway, this must be handled by serializer's staff.
Updated•3 years ago
|
Comment 8•1 year ago
|
||
Hello everyone,
I think that it's no problem to add =""
It is in fact a problem in some cases. For instance, this code:
<option selected>blah</option>
Will then get modified, when saving the page to disk, to:
<option selected="selected">blah</option>
However, if you're using JavaScript to save the HTML document (instead of using Ctrl+S), it might end up as selected="".
But if you're trying to run an HTML validator such as html-validate, with attribute-boolean-style rule, you'll get an error because selected is a boolean attribute and shouldn't have an empty string as value (in the context of the rule you chose to have).
To be precise, the spec allows for these 3 variations (naked, empty string, or attribute name). The problem here is the difference between what the server is actually sending / code shown in View source code (correctly shown without ="") and the code found after saving the html file on disk, which is different depending on how it was saved, and in no case similar to the "real" HTML sent by the server.
I understand this bug report was opened 22 years ago. Since then, spec has evolved, and I wish to propose that boolean attributes are allowed to stay "naked" in all cases. The issue here being about the browser allowing the user to access the exact same code that was sent by the server.
For reference: https://html.spec.whatwg.org/#boolean-attributes
Description
•