Merge pull request #4567 from koba04/fix-set-boolean-properties

Fixed consistency of behavior boolean properties
This commit is contained in:
Paul O’Shannessy
2015-08-19 10:20:49 -07:00
2 changed files with 12 additions and 0 deletions
@@ -177,6 +177,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.