Bug Tracker

Ticket #4878 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

val() tries to set multiple values on single select lists

Reported by: bennettmcelwee Owned by:
Priority: low Milestone: 1.4
Component: core Version: 1.3.2
Keywords: select val Cc:
Blocking: Blocked by:

Description

jQuery.fn.val(value) will select every matching option in a select list, even if it's not a multiple select list. It's invalid HTML for more than one option to be selected. When it happens, the browser has to pick one to display. Firefox and Safari pick the first selected option; IE6 picks the last.

Correct behaviour should probably be to select just the first matching value in these cases.

I'm attaching a patch to attributes.js rev 6333 that fixes the problem, along with a simple test page that shows the problem on IE6.

Attachments

attributes.js-r6333-patch.txt Download (417 bytes) - added by bennettmcelwee 5 years ago.
Patch for attributes.js rev 6333
val-singleselect-test.html Download (1.0 KB) - added by bennettmcelwee 5 years ago.
Test file showing the problem
attributes.diff Download (774 bytes) - added by bennettmcelwee 5 years ago.
Proper patch file for rev 6333.

Change History

Changed 5 years ago by bennettmcelwee

Patch for attributes.js rev 6333

Changed 5 years ago by bennettmcelwee

Test file showing the problem

Changed 5 years ago by bennettmcelwee

Proper patch file for rev 6333.

comment:1 Changed 4 years ago by dmethvin

  • Keywords needsreview added
  • Status changed from new to open

Should we try to force an error case into correct behavior?

comment:2 Changed 4 years ago by bennettmcelwee

This is not a problem any more, due to related changes in jQuery 1.4.

comment:3 Changed 4 years ago by jitter

  • Keywords needsreview removed
  • Priority changed from minor to low
  • Status changed from open to closed
  • Resolution set to fixed
  • Milestone set to 1.4

Closing as reporter confirmed this has been fixed with 1.4 already.

 test case

Note: See TracTickets for help on using tickets.