Skip to content

Cannot set numerical 0 values to form fields. #2164

Closed
rhuynh opened this Issue Dec 9, 2011 · 1 comment

2 participants

@rhuynh
rhuynh commented Dec 9, 2011

In mootools 1.4.2., you can no longer set a form field's value to 0, eg, myTextBox.set('value', 0). It always result in an empty string. This used to work in mootools 1.2.5.

I believe the error is in the property setter for 'value'. Instead of:

Object.append(propertySetters, {
'class': function(node, value){
('className' in node) ? node.className = (value || '') : node.setAttribute('class', value);
},
....
'value': function(node, value){
node.value = value || '';
}

});

it should be:

Object.append(propertySetters, {
'class': function(node, value){
('className' in node) ? node.className = (value || '') : node.setAttribute('class', value);
},
....
'value': function(node, value){
node.value = [value, ''].pick();
}

});

Tested On: Firefox, Safari, and IE9

jsFiddler:
http://jsfiddle.net/uYWgf/2/

@ibolmo
MooTools member
ibolmo commented Dec 9, 2011
@ibolmo ibolmo added a commit that closed this issue Jan 9, 2012
@ibolmo ibolmo Fixes #2164.
Changed value property setter was too strict with defaulting to an empty
string. Now Element.set('value') for falsey values depends on toString
of that object for setting the right value.

PASSED: IE6-9; FFx 3-5, 8; 10; Safari 5; Opera 11; Chrome latest
0b42256
@ibolmo ibolmo closed this in 0b42256 Jan 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.