Open
Bug 362321
Opened 18 years ago
Updated 2 years ago
XUL decks assume the selectedIndex attribute has been set
Categories
(Toolkit :: UI Widgets, defect)
Tracking
()
NEW
People
(Reporter: WeirdAl, Unassigned)
References
()
Details
If the XUL author hasn't set a selectedIndex attribute and later tries to set it to 0 (the number), the check for (this.getAttribute == val) returns true. This isn't nice. Per discussion on #developers, changing val to String(val) seems a good solution.
Comment 1•18 years ago
|
||
Maybe the getter should return || "0" ?
Comment 2•17 years ago
|
||
Maybe I don't really understand the problem here. The property should always return an integer. If no attribute was explicitly set it should return 0. Using getAttribute you always get a string. While this is usually clear to a developer the current situation is not. In current builds the deck returns a string for the selectedIndex property. While I usually assume to get an integer from such a property and the documentation at http://developer.mozilla.org/en/docs/XUL:deck and http://www.xulplanet.com/references/elemref/ref_deck.html#prop_selectedIndex says it's an integer this is pretty irritating. My following script to toggle a deck's view doesn't work because of that: var deck = document.getElementById("propertiesDeck"); deck.selectedIndex = (deck.selectedIndex+1)%2; as "deck.selectedIndex+1" is always becomming "11" instead of 2. My current workaround is to convert the selectedIndex property to an int. deck.selectedIndex = (parseInt(deck.selectedIndex)+1)%2; Either documentation should be fixes or the property should return an integer (which I think is the much better solution).
Comment 3•17 years ago
|
||
(In reply to comment #2) > My current workaround is to convert the selectedIndex property to an int. > > deck.selectedIndex = (parseInt(deck.selectedIndex)+1)%2; This should read: deck.selectedIndex = (parseInt(deck.selectedIndex||0)+1)%2; Otherwise the first change never happens because selectedIndex returns an empty string and parseInt("") returns NaN.
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•