Skip to content
This repository

Cannot set numerical 0 values to form fields. #2164

Closed
rhuynh opened this Issue December 09, 2011 · 1 comment

2 participants

Rick Huynh Olmo Maldonado
Rick Huynh

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/

Olmo Maldonado
Owner
Olmo Maldonado ibolmo closed this issue from a commit January 09, 2012
Olmo Maldonado 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
Olmo Maldonado ibolmo closed this in 0b42256 January 09, 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.