New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-element-to-jsx-string

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-element-to-jsx-string - npm Package Compare versions

Comparing version

to
2.0.2

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="2.0.2"></a>
## [2.0.2](https://github.com/algolia/react-element-to-jsx-string/compare/v2.0.1...v2.0.2) (2015-10-16)
### Bug Fixes
* **children:** ensure the array of children is well handled ([36b462a](https://github.com/algolia/react-element-to-jsx-string/commit/36b462a))
<a name="2.0.1"></a>

@@ -2,0 +12,0 @@ ## [2.0.1](https://github.com/algolia/react-element-to-jsx-string/compare/v2.0.0...v2.0.1) (2015-10-16)

8

index-dist.js

@@ -48,4 +48,6 @@ 'use strict';

if (!(0, _reactAddonsTestUtils.isElement)(ReactElement)) {
throw new Error('react-element-to-jsx-string: Expected a ReactElement');
if (typeof ReactElement === 'string') {
return ReactElement;
} else if (!(0, _reactAddonsTestUtils.isElement)(ReactElement)) {
throw new Error('react-element-to-jsx-string: Expected a ReactElement, ' + 'got `' + typeof ReactElement + '`');
}

@@ -90,3 +92,3 @@

} else {
out += _react2['default'].Children.toArray(children).map(recurse({ lvl: lvl, inline: inline }));
out += _react2['default'].Children.toArray(children).map(recurse({ lvl: lvl, inline: inline })).join('\n' + spacer(lvl));
}

@@ -93,0 +95,0 @@ if (!inline) {

@@ -202,2 +202,20 @@ /* eslint-env mocha */

});
it(`reactElementToJSXString(<div><span /><span /></div>)`, () => {
expect(
reactElementToJSXString(<div><span /><span /></div>)
).toEqual(`<div>
<span />
<span />
</div>`);
});
it(`reactElementToJSXString(<div>foo<div /></div>)`, () => {
expect(
reactElementToJSXString(<div>foo<div /></div>)
).toEqual(`<div>
foo
<div />
</div>`);
});
});

@@ -14,4 +14,7 @@ import React from 'react';

function toJSXString({ReactElement = null, lvl = 0, inline = false}) {
if (!isElement(ReactElement)) {
throw new Error('react-element-to-jsx-string: Expected a ReactElement');
if (typeof ReactElement === 'string') {
return ReactElement;
} else if (!isElement(ReactElement)) {
throw new Error('react-element-to-jsx-string: Expected a ReactElement, ' +
'got `' + (typeof ReactElement) + '`');
}

@@ -62,3 +65,3 @@

recurse({lvl, inline})
);
).join('\n' + spacer(lvl));
}

@@ -65,0 +68,0 @@ if (!inline) {

{
"name": "react-element-to-jsx-string",
"version": "2.0.1",
"version": "2.0.2",
"description": "Turn a ReactElement into the corresponding JSX string.",

@@ -5,0 +5,0 @@ "main": "index-dist.js",