Bug Tracker

Modify

Ticket #5394 (closed bug: duplicate)

Opened 4 years ago

Last modified 2 years ago

Discrepancy of $(...).val(missing_option) bevahiour between IE, FF and Safari

Reported by: olksy Owned by: olksy
Priority: low Milestone:
Component: attributes Version: 1.5.2
Keywords: Cc:
Blocking: Blocked by:

Description

This ticket is about SELECT control behavior.

missing_option is option that is not in SELECT's option list.

In FF, IE $( select ).val( missing_option ) will not change the selection.

In Safari that will cause selecting non-existent blank option. Then, if I as user select any existing option back, blank option goes away.

I have no idea, which behavior is preferred. But it would be nice to have consistency.

Safari is 4.0.3

Change History

comment:1 Changed 4 years ago by dmethvin

These edge cases can take a lot of code to nail down but don't seem that common. If there isn't a clear "right way" to do it, perhaps the best thing to do would be to explicitly specify the behavior you want for that case. Otherwise even if jQuery tried to normalize all the browser behaviors it might not do it the way you require, and you'd be back to writing explicit code to handle the case.

comment:2 Changed 3 years ago by dmethvin

  • Component changed from unfiled to attributes

comment:3 Changed 3 years ago by snover

  • Owner set to olksy
  • Status changed from new to pending

Could you please confirm this is still an issue in the current version of jQuery?

comment:4 Changed 3 years ago by dmethvin

  • Status changed from pending to open

 http://jsfiddle.net/dmethvin/5XJHv/

Firefox, IE, and Opera return the first element's value when an invalid value is assigned; Safari and Chrome return null for the value.

comment:5 Changed 2 years ago by timmywil

  • Priority changed from minor to low
  • Status changed from open to closed
  • Version changed from 1.3.2 to 1.5.2
  • Resolution set to duplicate
  • Type changed from enhancement to bug

comment:6 Changed 2 years ago by timmywil

Duplicate of #8813.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.