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:
Cheng Lou
2014-03-25 12:31:12 -07:00
committed by Paul O’Shannessy
parent 116ee058eb
commit edc0fa4c3f
2 changed files with 36 additions and 1 deletions
+1 -1
View File
@@ -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');