mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixed consistency of behavior boolean properties
This commit is contained in:
@@ -173,6 +173,9 @@ var DOMPropertyOperations = {
|
||||
// ('' + value) makes it output the correct toString()-value.
|
||||
if (namespace) {
|
||||
node.setAttributeNS(namespace, attributeName, '' + value);
|
||||
} else if (propertyInfo.hasBooleanValue ||
|
||||
(propertyInfo.hasOverloadedBooleanValue && value === true)) {
|
||||
node.setAttribute(attributeName, '');
|
||||
} else {
|
||||
node.setAttribute(attributeName, '' + value);
|
||||
}
|
||||
|
||||
@@ -224,6 +224,15 @@ describe('DOMPropertyOperations', function() {
|
||||
.toEqual(['http://www.w3.org/1999/xlink', 'xlink:href', 'about:blank']);
|
||||
});
|
||||
|
||||
it('should set values as boolean properties', function() {
|
||||
DOMPropertyOperations.setValueForProperty(stubNode, 'disabled', 'disabled');
|
||||
expect(stubNode.getAttribute('disabled')).toBe('');
|
||||
DOMPropertyOperations.setValueForProperty(stubNode, 'disabled', true);
|
||||
expect(stubNode.getAttribute('disabled')).toBe('');
|
||||
DOMPropertyOperations.setValueForProperty(stubNode, 'disabled', false);
|
||||
expect(stubNode.getAttribute('disabled')).toBe(null);
|
||||
});
|
||||
|
||||
it('should convert attribute values to string first', function() {
|
||||
// Browsers default to this behavior, but some test environments do not.
|
||||
// This ensures that we have consistent behavior.
|
||||
|
||||
Reference in New Issue
Block a user