Skip to content

Commit

Permalink
Fixed consistency of behavior boolean properties
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Aug 9, 2015
1 parent c97ed7b commit eb4e44a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/renderers/dom/shared/DOMPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit eb4e44a

Please sign in to comment.