Skip to content

Commit

Permalink
Fix an issue with val() returning invalid values on Chrome for Android,
Browse files Browse the repository at this point in the history
fixes madrobby#870.

Note that this fix exposes an issue where `removeAttr` doesn't correctly
remove the `selected` attribute from `option` elements on IE. This will
be handled in a seperate fix.
  • Loading branch information
madrobby committed Dec 1, 2013
1 parent ce4787b commit 9cf3adf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/zepto.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ var Zepto = (function() {
val: function(value){
return arguments.length === 0 ?
(this[0] && (this[0].multiple ?
$(this[0]).find('option').filter(function(o){ return this.selected }).pluck('value') :
$(this[0]).find('option[selected]').pluck('value') :
this[0].value)
) :
this.each(function(idx){
Expand Down
2 changes: 1 addition & 1 deletion test/zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@ <h1>Zepto DOM unit tests</h1>
$('<select multiple><option selected>1</option><option value=2 selected="selected">a</option><option>3</option></select>')
t.assertEqualCollection(['1','2'], multiple.val())

multiple.find('option')[0].selected = false
$(multiple.find('option').get(0)).removeAttr('selected')
t.assertEqualCollection(['2'], multiple.val())
},

Expand Down

0 comments on commit 9cf3adf

Please sign in to comment.