Closed
Bug 1346281
Opened 8 years ago
Closed 8 years ago
Contradictory advice in Mozilla developer Web API Element.setAttribute() docs
Categories
(Developer Documentation Graveyard :: General, defect, P5)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: karen_dolan, Unassigned)
References
()
Details
:: Developer Documentation Request
Request Type: Correction
Gecko Version: unspecified
Technical Contact:
:: Details
The Mozilla dev setAttribute documentation says:
"elt.setAttribute(attr, null) [...] will coerce the null value to the string "null", which is likely not what you want."
Then a few lines later says:
"To set an attribute that takes no value, such as the autoplay attribute of an <audio> element, use a null or empty value. For example: elt.setAttribute('autoplay', '')" . It just said it's ok to null OR empty value there!
So, is it Ok or not Ok to use elt.setAttribute(attr, null)?
FYI - According to W3C, to set an attribute that takes no value... don't use null:
"Empty attribute syntax
Just the attribute name. The value is implicitly the empty string."
The attribute’s name is the value of attribute name, its value is the empty string."
https://www.w3.org/TR/html/syntax.html#syntax-attr-empty
Comment 1•8 years ago
|
||
I've updated the Element.setAttribute() page accordingly. I've made numerous other improvements, too. Still needs a browser compat table, but it's progress.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•