mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
assertValidProps for updating DOM components through renderComponent
`renderComponent(<div style={invalidType}/>, container)` throws correctly,
but not when it's called a second time (i.e. updating rather than mounting).
It goes through `ReactDOMComponent.updateComponent` but there wasn't a
props assertion there.
(Removed the assertion in `receiveComponent`)
This commit is contained in:
committed by
Paul O’Shannessy
parent
116ee058eb
commit
edc0fa4c3f
@@ -215,7 +215,6 @@ ReactDOMComponent.Mixin = {
|
||||
return;
|
||||
}
|
||||
|
||||
assertValidProps(nextComponent.props);
|
||||
ReactComponent.Mixin.receiveComponent.call(
|
||||
this,
|
||||
nextComponent,
|
||||
@@ -236,6 +235,7 @@ ReactDOMComponent.Mixin = {
|
||||
'ReactDOMComponent',
|
||||
'updateComponent',
|
||||
function(transaction, prevProps, prevOwner) {
|
||||
assertValidProps(this.props);
|
||||
ReactComponent.Mixin.updateComponent.call(
|
||||
this,
|
||||
transaction,
|
||||
|
||||
@@ -340,6 +340,41 @@ describe('ReactDOMComponent', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('updateComponent', function() {
|
||||
var React;
|
||||
var container;
|
||||
|
||||
beforeEach(function() {
|
||||
React = require('React');
|
||||
container = document.createElement('div');
|
||||
});
|
||||
|
||||
it("should validate against multiple children props", function() {
|
||||
React.renderComponent(<div></div>, container);
|
||||
|
||||
expect(function() {
|
||||
React.renderComponent(
|
||||
<div children="" dangerouslySetInnerHTML={{__html: ''}}></div>,
|
||||
container
|
||||
);
|
||||
}).toThrow(
|
||||
'Invariant Violation: Can only set one of `children` or ' +
|
||||
'`props.dangerouslySetInnerHTML`.'
|
||||
);
|
||||
});
|
||||
|
||||
it("should validate against invalid styles", function() {
|
||||
React.renderComponent(<div></div>, container);
|
||||
|
||||
expect(function() {
|
||||
React.renderComponent(<div style={1}></div>, container);
|
||||
}).toThrow(
|
||||
'Invariant Violation: The `style` prop expects a mapping from style ' +
|
||||
'properties to values, not a string.'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unmountComponent', function() {
|
||||
it("should clean up listeners", function() {
|
||||
var React = require('React');
|
||||
|
||||
Reference in New Issue
Block a user