On Dec 21, 10:32 pm, John Resig <jere...@gmail.com> wrote:
> > Agreed, the change is broken! Wasn't there a test case for the above
> > scenario?
> The previous technique was definitely not the right one to use. Cases
> were coming up where the same string was being used for the value and
> the text in different places and it couldn't figure out what to
> select.
> See the previous 
> discussion/ticket/changeset:http://groups.google.com/group/jquery-dev/browse_thread/thread/74dddc...

Looks like the quick code changed wasn't thought through enough. The
correct algorithm needs to be decided on, rather than quick-fixing a
bug report. It shouldn't matter whether a situation "makes sense" or
whether someone would actually do it in practice. The specs are very
specific about how controls should function under all scenarios,
whether it "makes sense" or not.

Selecting options based on their text, regardless of value, seems to
make the method results confusing. Because you aren't actually setting
the value, then, you're setting some unknown value that corresponds to
the text value that you have matched.

Consider the following cases:

#1)
<select id="x">
  <option value="1">Dummy</option>
  <option value="">Empty</option>
</select>

  $('#x').val('')
should select the second option.

#2)
<select id="x">
  <option value="x">z</option>
  <option value="y">x</option>
</select>

  $('#x').val('x')
should select the first option only.

#3)
<select id="x">
  <option value="x">y</option>
  <option>y</option>
</select>

  $('#x').val('y')
should select the second option only.

#4)
<select multiple id="x">
  <option value="x">z</option>
  <option value="y">x</option>
</select>

  $('#x').val('x')
should select the first option only, IMO. It's kind of ambiguous and
jQuery should define what it wants to do.

Matt Kruse

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to