diff --git a/src/renderers/dom/shared/DOMPropertyOperations.js b/src/renderers/dom/shared/DOMPropertyOperations.js index 20491d9d5b..84b52089be 100644 --- a/src/renderers/dom/shared/DOMPropertyOperations.js +++ b/src/renderers/dom/shared/DOMPropertyOperations.js @@ -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); } diff --git a/src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js b/src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js index 3587a0e125..c4b96b4cc6 100644 --- a/src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js +++ b/src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js @@ -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.