Fix removing DOM property with mapped name

This commit is contained in:
Ben Alpert
2014-03-06 00:30:40 -08:00
parent af1b63456e
commit 21e06196cd
2 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -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) {
@@ -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() {