@samitouri / QOS-React-2 / commits / 70c07c67b7

resolves issue #4168, style prop error now names React class that erroring element is a child of.

Niole Nelson committed Jul 24, 2015 at 18:36 UTC 70c07c67b74b7c62c524f80f7e7b27a8e09eb7f1
2 files changed +19 -1
src/renderers/dom/shared/ReactDOMComponent.js
+2 -1
@@ -261,7 +261,8 @@ function assertValidProps(component, props) {
261 props.style == null || typeof props.style === 'object',
262 'The `style` prop expects a mapping from style properties to values, ' +
263 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
264 - 'using JSX.'
264 + 'using JSX.%s',
265 + getDeclarationErrorAddendum(component)
266 );
267 }
268
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+17
@@ -721,6 +721,23 @@ describe('ReactDOMComponent', function() {
721 );
722 });
723
724 + it('should report component containing invalid styles', function() {
725 + var Animal = React.createClass({
726 + render: function() {
727 + return <div style={1}></div>;
728 + },
729 + });
730 +
731 + expect(function() {
732 + React.render(<Animal/>, container);
733 + }).toThrow(
734 + 'Invariant Violation: The `style` prop expects a mapping from style ' +
735 + 'properties to values, not a string. For example, ' +
736 + 'style={{marginRight: spacing + \'em\'}} when using JSX. ' +
737 + 'This DOM node was rendered by `Animal`.'
738 + );
739 + });
740 +
741 it('should properly escape text content and attributes values', function() {
742 expect(
743 ReactDOMServer.renderToStaticMarkup(