Skip to content

Commit

Permalink
Merge pull request #1225 from spicyj/cprop
Browse files Browse the repository at this point in the history
Fix removing DOM property with mapped name
  • Loading branch information
zpao committed Mar 10, 2014
2 parents d9dd9d5 + 21e0619 commit 2ca810f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/browser/ui/dom/DOMPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var DOMPropertyOperations = {
var propName = DOMProperty.getPropertyName[name];
var defaultValue = DOMProperty.getDefaultValueForProperty(
node.nodeName,
name
propName
);
if (!DOMProperty.hasSideEffects[name] ||
node[propName] !== defaultValue) {
Expand Down
27 changes: 27 additions & 0 deletions src/browser/ui/dom/__tests__/DOMPropertyOperations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,33 @@ describe('DOMPropertyOperations', function() {
expect(stubNode.className).toBe('');
});

it('should remove property properly even with different name', function() {
// Suppose 'foobar' is a property that corresponds to the underlying
// 'className' property:
DOMProperty.injection.injectDOMPropertyConfig({
Properties: {foobar: DOMProperty.injection.MUST_USE_PROPERTY},
DOMPropertyNames: {
foobar: 'className'
}
});

DOMPropertyOperations.setValueForProperty(
stubNode,
'foobar',
'selected'
);
expect(stubNode.className).toBe('selected');

DOMPropertyOperations.setValueForProperty(
stubNode,
'foobar',
null
);
// className should be '', not 'null' or null (which becomes 'null' in
// some browsers)
expect(stubNode.className).toBe('');
});

});

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

0 comments on commit 2ca810f

Please sign in to comment.