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 set `hidden="true"` in the markup - Setting `el.hidden = false` or any falsy value will remove the `hidden` 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 set `hidden=""` in the markup - Setting `el.hidden = false` or any falsy value will remove the `hidden` 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"]` - Rewrite current JS consumers of `setAttribute("hidden", ...)` to use `toggleAttribute` or `.hidden = ...` - As bgrins pointed out, some platform code is reading those attributes too: - https://searchfox.org/mozilla-central/source/dom/xul/nsXULElement.h#427 - https://searchfox.org/mozilla-central/source/widget/cocoa/nsMenuUtilsX.mm#176 - we should be careful about XUL persistance.
Bug 1592799 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
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 set `hidden="true"` in the markup - Setting `el.hidden = false` or any falsy value will remove the `hidden` 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 set `hidden=""` in the markup - Setting `el.hidden = false` or any falsy value will remove the `hidden` 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 use `toggleAttribute` or the correct values. - As bgrins pointed out, some platform code is reading those attributes too: - https://searchfox.org/mozilla-central/source/dom/xul/nsXULElement.h#427 - https://searchfox.org/mozilla-central/source/widget/cocoa/nsMenuUtilsX.mm#176 - we should be careful about XUL persistance.