mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix removing DOM property with mapped name
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user