Skip to content

Commit

Permalink
Fixes #2041 - Add Element.Properties.values.set so it works x-browser…
Browse files Browse the repository at this point in the history
… when the value attribute of option elements is not set
  • Loading branch information
Arian committed Aug 27, 2011
1 parent 82dcfc8 commit a0a1470
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/Element/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,16 +915,30 @@ var testForm = document.createElement('form');
testForm.innerHTML = '<select><option>s</option></select>';

if (testForm.firstChild.value != 's') Element.Properties.value = {

set: function(value){
var tag = this.get('tag');
if (tag != 'select') return this.setProperty('value', value);
var options = this.getElements('option');
for (var i = 0; i < options.length; i++){
var option = options[i],
attr = option.getAttributeNode('value'),
optionValue = (attr && attr.specified) ? option.value : option.get('text');
if (optionValue == value) return option.selected = true;
}
},

get: function(){
var option = this, tag = option.get('tag');

if (tag != 'select' && tag != 'option') return this.getProperty('value');

if (tag == 'select') if (!(option = option.getSelected()[0])) return '';
if (tag == 'select' && !(option = option.getSelected()[0])) return '';

var attr = option.getAttributeNode('value');
return (attr && attr.specified) ? option.value : option.get('text');
}

};
/*</ltIE9>*/

Expand Down

0 comments on commit a0a1470

Please sign in to comment.