diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index 4301b3438e..c06e3e1fc1 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -261,7 +261,8 @@ function assertValidProps(component, props) { props.style == null || typeof props.style === 'object', 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + - 'using JSX.' + 'using JSX.%s', + getDeclarationErrorAddendum(component) ); } diff --git a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js index 55bb5c5748..21da279ab0 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js @@ -721,6 +721,23 @@ describe('ReactDOMComponent', function() { ); }); + it('should report component containing invalid styles', function() { + var Animal = React.createClass({ + render: function() { + return
; + }, + }); + + expect(function() { + React.render(, container); + }).toThrow( + 'Invariant Violation: The `style` prop expects a mapping from style ' + + 'properties to values, not a string. For example, ' + + 'style={{marginRight: spacing + \'em\'}} when using JSX. ' + + 'This DOM node was rendered by `Animal`.' + ); + }); + it('should properly escape text content and attributes values', function() { expect( ReactDOMServer.renderToStaticMarkup(