Skip to content

Commit

Permalink
Add test coverage for setAttribute update. Remove hasAttribute check
Browse files Browse the repository at this point in the history
  • Loading branch information
nhunzaker committed Aug 1, 2016
1 parent 162eee8 commit 151bc11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/renderers/dom/shared/DOMPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ var DOMPropertyOperations = {
} else if (propertyInfo.hasBooleanValue ||
(propertyInfo.hasOverloadedBooleanValue && value === true)) {
node.setAttribute(attributeName, '');
} else if (attributeName === 'value' && node.hasAttribute('value')) {
} else if (attributeName === 'value') {
// Use loose coercion to prevent replacement on comparisons like
// '3e1' == 30 in Chrome (~52).
if (node.value != value) { // eslint-disable-line
Expand Down
10 changes: 10 additions & 0 deletions src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ describe('DOMPropertyOperations', function() {
expect(stubNode.className).toBe('');
});

it('should not update numeric values when the input.value is loosely the same', function() {
stubNode.setAttribute('type', 'number');
stubNode.value = '3e1';

spyOn(stubNode, 'setAttribute');

DOMPropertyOperations.setValueForProperty(stubNode, 'value', 30);

expect(stubNode.setAttribute.calls.count()).toBe(0);
});
});

describe('deleteValueForProperty', function() {
Expand Down

0 comments on commit 151bc11

Please sign in to comment.