Snippets code from my daily experience

January 25, 2009

XUL developers please add id attribute to elements (Sunday Thought)

Filed under: sunday_thought,xul — dafi @ 1:00 pm

The XUL overlay mechanism is great, it allows to extend virtually any UI widget.

Damn, why developers continue to forget to add id attributes to elements candidate to be re-used (ie all)?

Please dear developers follow these simple rules

  • Please don’t forget windows and dialogs or simply refer to this short list 😛
  • Please don’t forget menu and menuitems (not generated dinamically)
  • Add id attribute to every element
  • Add id attribute to every element (#1)
  • Add id attribute to every element (#2)
  • Add id attribute to every element (#n)

iwilluseid

Based on my experience no application is fully compliant: Firefox, Thunderbird, SeaMonkey and also Komodo contain elements I needed to access without an associated id attribute

How to survive to bad practices

Sometimes (but not always) it is possible to use some workaround.
Consider that workarounds can be worst than initial problem

  • Find target element with getAttributesByName method, it is especially useful for menuitems passing the ‘value’ attribute
  • Find an element closer to the target using its id then navigate DOM with methods/attributes like firstChild & co.
Advertisements

Blog at WordPress.com.