Open Bug 361893 Opened 18 years ago Updated 2 years ago

Menulist: setting selectedIndex or setAttribute('label', ...) sends wrong DOMAttrModified events

Categories

(Toolkit :: UI Widgets, defect)

x86
Windows 2000
defect

Tracking

()

People

(Reporter: gekacheka, Unassigned)

Details

Attachments

(1 file)

Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20061125 Calendar/0.4a1

Setting 
  menulist.selectedIndex = N
sends 3 DOMAttrModified events:
1. e1.attrName='value', e1.prevValue='old Value', e1.newValue='new Value'
2. e2.attrName='value', e2.prevValue='old Label', e2.newValue='new Label'
3. e3.attrName='label', e3.prevValue='old Label', e3.newValue='new Label'

#2 above is wrong and should not be sent: it is wrong to provide Label attribute values for the Value attribute change.  Any listener observing Value changes will see invalid values.  The later invalid 'value' event (e2) will override the earlier valid 'value' event (e1).

Directly setting
  menulist.setAttribute('label', newLabel);
sends 2 DOMAttrModified events
1. e1.attrName='value', e1.prevValue='old Label', e1.newValue='new Label'
2. e2.attrName='label', e2.prevValue='old Label', e2.newValue='new Label'

#1 above is wrong and should not be sent: it is wrong to provide Label values for the Value attribute change.  Any listener observing Value changes will see invalid values.
Likely invalid. One of the mutation events is actually from the anonymous label inside the menulist.

For XBL2, though, this should not occur, as mutation events don't propagate outside of anonymous content.
The event listener in the test case only logs events where the menulist is the event.target.  

An event from an anonymous label node should have that label node as the event.target, not the menulist.
(In reply to comment #3)
> The event listener in the test case only logs events where the menulist is the
> event.target.  
> 
> An event from an anonymous label node should have that label node as the
> event.target, not the menulist.
> 

No, it should have the menulist as the target, and the label as the originalTarget.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: