interpolate-components
Advanced tools
Comparing version
@@ -6,2 +6,3 @@ # Changelog | ||
* Bump to allow for React ^16.0.0 | ||
* Drop deprecated React.createClass, React.DOM from test | ||
@@ -8,0 +9,0 @@ ## 1.1.0 |
@@ -7,5 +7,5 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; /** | ||
* External Dependencies | ||
*/ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /** | ||
* External Dependencies | ||
*/ | ||
@@ -56,3 +56,2 @@ | ||
var children = [], | ||
childrenObject = {}, | ||
openComponent, | ||
@@ -93,3 +92,5 @@ clonedOpenComponent, | ||
// componentSelfClosing token | ||
children.push(components[token.value]); | ||
if (components[token.value]) { | ||
children.push(_react2.default.cloneElement(components[token.value], { key: i })); | ||
} | ||
continue; | ||
@@ -102,3 +103,3 @@ } | ||
grandChildren = buildChildren(grandChildTokens, components); | ||
clonedOpenComponent = _react2.default.cloneElement(openComponent, {}, grandChildren); | ||
clonedOpenComponent = _react2.default.cloneElement(openComponent, { key: openIndex }, grandChildren); | ||
children.push(clonedOpenComponent); | ||
@@ -117,13 +118,9 @@ | ||
return children.map(function (child, index) { | ||
if (child) { | ||
return _react2.default.cloneElement(child, { key: 'interpolation-child-' + index }, child.props !== undefined ? child.props.children : undefined); | ||
} | ||
}); | ||
return children; | ||
} | ||
function interpolate(options) { | ||
var mixedString = options.mixedString; | ||
var components = options.components; | ||
var throwErrors = options.throwErrors; | ||
var mixedString = options.mixedString, | ||
components = options.components, | ||
throwErrors = options.throwErrors; | ||
@@ -130,0 +127,0 @@ |
{ | ||
"name": "interpolate-components", | ||
"version": "1.1.1-alpha.1", | ||
"version": "1.1.1-alpha.2", | ||
"description": "Convert strings into structured React components.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -14,12 +14,9 @@ /** | ||
describe( 'interpolate-components', () => { | ||
const input = React.DOM.input(); | ||
const div = React.DOM.div(); | ||
const input = <input />; | ||
const div = <div />; | ||
const link = <a href="#" />; | ||
const em = <em />; | ||
const CustomComponentClass = React.createClass( { | ||
displayName: 'CustomComponentClass', | ||
render() { | ||
return <span className="special">{ this.props.intro }{ this.props.children }</span>; | ||
} | ||
} ); | ||
const CustomComponentClass = ( { children, intro } ) => ( | ||
<span className="special">{ intro }{ children }</span> | ||
); | ||
@@ -26,0 +23,0 @@ describe( 'with default container', () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
41872
1.18%0
-100%403
-1.47%