Open Bug 1592799 Opened 5 years ago Updated 2 years ago

Replace XUL-style boolean attributes with HTML-style when appropriate

Categories

(Toolkit :: Themes, task, P3)

task

Tracking

()

People

(Reporter: ntim, Unassigned)

References

(Depends on 2 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 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:

See Also: → 1580983
See Also: → 1593023
See Also: → 1593303
Blocks: 1580983
See Also: 1580983

(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)

(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.

See Also: → 1593848
Priority: -- → P3
Depends on: 1604156
Depends on: 1691274
Depends on: 1691310
Depends on: 1691313
Depends on: 1691314
Depends on: 1691315
Summary: Use HTML-style boolean attributes for XUL hidden and collapsed attributes → Replace XUL-style boolean attributes with HTML-style when appropriate
Depends on: 1691321
No longer depends on: 1691274, 1691313, 1691314, 1691315

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 for disabled. In particular, the following cases:

  1. button has command attribute, command gets disabled attribute (button gets it too), button's command attribute gets removed, command gets disabled attribute removed, button's command attribute is reinstated (button still has disabled attribute; the removal won't propagate)
  2. button has command attribute, command gets disabled attribute set to true (button gets it too), button's command attribute gets removed, command gets disabled attribute set to false, button's command attribute is reinstated (button gets its disabled attribute set to false)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.