mootools/mootools-core — Issue #2164: Cannot set numerical 0 values to form fields.
Author: rhuynh
Created: 2011-12-09 16:55:08+00:00
State: open

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/