Replace XUL-style boolean attributes with HTML-style when appropriate
Categories
(Toolkit :: Themes, task, P3)
Tracking
()
People
(Reporter: ntim, Unassigned)
References
(Depends on 3 open bugs, Blocks 3 open bugs)
Details
Currently, the XUL hidden
and collapsed
attributes are "XUL-style" boolean attributes, which means:
- Only a value of
true
hides or collapses the element in the XUL markup - Setting
el.hidden = true
or any truthy value will sethidden="true"
in the markup - Setting
el.hidden = false
or any falsy value will remove thehidden
attribute
It'd be nice to switch to "HTML-style" boolean attributes:
- Setting any value to the
hidden
/collapsed
HTML attribute will hide the element - Setting
el.hidden = true
or any truthy value will sethidden=""
in the markup - Setting
el.hidden = false
or any falsy value will remove thehidden
attribute - The recommended way to write things in HTML markup is
<div hidden>
- The recommended way to write things in XHTML markup is
<div hidden="hidden">
The current plan would be:
- Switch the current CSS to read for
[hidden]
rather than[hidden="true"]
, ditto for collapsed - Rewrite current JS consumers of
setAttribute("hidden", ...)
to use.hidden = ...
- Rewrite current JS consumers of
setAttribute("collapsed", ...)
to usetoggleAttribute
or the correct values. - As bgrins pointed out, some platform code is reading those attributes too:
- we should be careful about XUL persistance.
Updated•5 years ago
|
(In reply to Tim Nguyen :ntim from comment #0)
It'd be nice to switch to "HTML-style" boolean attributes:
- The recommended way to write things in HTML markup is
<div hidden>
- The recommended way to write things in XHTML markup is
<div hidden="hidden">
FWIW, I use <div hidden="true">
in my XHTML files, since the attribute’s value doesn’t matter in HTML, and XML requires all attributes to have some value. (this restriction will be lifted in XML5)
Reporter | ||
Comment 2•5 years ago
|
||
(In reply to ExE Boss from comment #1)
(In reply to Tim Nguyen :ntim from comment #0)
It'd be nice to switch to "HTML-style" boolean attributes:
- The recommended way to write things in HTML markup is
<div hidden>
- The recommended way to write things in XHTML markup is
<div hidden="hidden">
FWIW, I use
<div hidden="true">
in my XHTML files, since the attribute’s value doesn’t matter in HTML, and XML requires all attributes to have some value. (this restriction will be lifted in XML5)
The HTML spec explicitely says not to use true
and false
. It makes sense because those values are misleading: hidden=false
will also hide the item. hidden=hidden
or hidden=""
are the recommended way on that spec.
Updated•5 years ago
|
Updated•5 years ago
|
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 3•4 years ago
|
||
Gijs mentioned in https://phabricator.services.mozilla.com/D104820 that XUL attribute broadcasting will need more care:
I think for
hidden
this might be OK, but it's worth pointing out that XUL attribute broadcasting works differently for attribute removal vs. attributes being set to something, which can bite us if we were to do the same fordisabled
. In particular, the following cases:
- button has
command
attribute, command gets disabled attribute (button gets it too), button'scommand
attribute gets removed, command gets disabled attribute removed, button'scommand
attribute is reinstated (button still hasdisabled
attribute; the removal won't propagate)- button has
command
attribute, command gets disabled attribute set to true (button gets it too), button'scommand
attribute gets removed, command gets disabled attribute set to false, button'scommand
attribute is reinstated (button gets itsdisabled
attribute set tofalse
)
Updated•2 years ago
|
Description
•