Cannot set numerical 0 values to form fields. #2164

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

Projects

None yet

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
Member
ibolmo commented Dec 9, 2011

Nice find. I'll spec this and get this committed 1.4.3 due out in less than
a week.

On Fri, Dec 9, 2011 at 10:55 AM, rhuynh <
reply@reply.github.com

wrote:

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/


Reply to this email directly or view it on GitHub:
#2164

@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