mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
(cherry picked from commit 0e889d7c72)
This commit is contained in:
committed by
Paul O’Shannessy
parent
5d3920f5ab
commit
3bf315d70e
@@ -206,6 +206,24 @@ var DOMPropertyOperations = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes an attributes from a node.
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {string} name
|
||||
*/
|
||||
deleteValueForAttribute: function(node, name) {
|
||||
node.removeAttribute(name);
|
||||
if (__DEV__) {
|
||||
ReactDOMInstrumentation.debugTool.onDeleteValueForProperty(node, name);
|
||||
ReactInstrumentation.debugTool.onNativeOperation(
|
||||
ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
|
||||
'remove attribute',
|
||||
name
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes the value for a property on a node.
|
||||
*
|
||||
|
||||
@@ -904,6 +904,13 @@ ReactDOMComponent.Mixin = {
|
||||
// listener (e.g., onClick={null})
|
||||
deleteListener(this, propKey);
|
||||
}
|
||||
} else if (isCustomComponent(this._tag, lastProps)) {
|
||||
if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
|
||||
DOMPropertyOperations.deleteValueForAttribute(
|
||||
getNode(this),
|
||||
propKey
|
||||
);
|
||||
}
|
||||
} else if (
|
||||
DOMProperty.properties[propKey] ||
|
||||
DOMProperty.isCustomAttribute(propKey)) {
|
||||
|
||||
@@ -302,6 +302,15 @@ describe('ReactDOMComponent', function() {
|
||||
expect(container.firstChild.className).toEqual('');
|
||||
});
|
||||
|
||||
it('should properly update custom attributes on custom elements', function() {
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(<some-custom-element foo="bar"/>, container);
|
||||
ReactDOM.render(<some-custom-element bar="buzz"/>, container);
|
||||
var node = container.firstChild;
|
||||
expect(node.hasAttribute('foo')).toBe(false);
|
||||
expect(node.getAttribute('bar')).toBe('buzz');
|
||||
});
|
||||
|
||||
it('should clear a single style prop when changing `style`', function() {
|
||||
var styles = {display: 'none', color: 'red'};
|
||||
var container = document.createElement('div');
|
||||
|
||||
Reference in New Issue
Block a user