react-highlight-words
Advanced tools
Comparing version 0.15.0 to 0.15.1
@@ -91,4 +91,2 @@ module.exports = | ||
var _react2 = _interopRequireDefault(_react); | ||
var _memoizeOne = __webpack_require__(15); | ||
@@ -153,3 +151,3 @@ | ||
var HighlightTag = highlightTag; | ||
var highlightCount = -1; | ||
var highlightIndex = -1; | ||
var highlightClassNames = ''; | ||
@@ -167,10 +165,9 @@ var highlightStyles = undefined; | ||
return _react2['default'].createElement( | ||
'span', | ||
{ className: className }, | ||
chunks.map(function (chunk, index) { | ||
return (0, _react.createElement)('span', { | ||
className: className, | ||
children: chunks.map(function (chunk, index) { | ||
var text = textToHighlight.substr(chunk.start, chunk.end - chunk.start); | ||
if (chunk.highlight) { | ||
highlightCount++; | ||
highlightIndex++; | ||
@@ -189,3 +186,3 @@ var highlightClass = undefined; | ||
var isActive = highlightCount === +activeIndex; | ||
var isActive = highlightIndex === +activeIndex; | ||
@@ -195,25 +192,26 @@ highlightClassNames = highlightClass + ' ' + (isActive ? activeClassName : ''); | ||
return _react2['default'].createElement( | ||
HighlightTag, | ||
{ | ||
className: highlightClassNames, | ||
highlightIndex: highlightCount, | ||
key: index, | ||
style: highlightStyles | ||
}, | ||
text | ||
); | ||
var props = { | ||
children: text, | ||
className: highlightClassNames, | ||
key: index, | ||
style: highlightStyles | ||
}; | ||
// Don't attach arbitrary props to DOM elements; this triggers React DEV warnings (https://fb.me/react-unknown-prop) | ||
// Only pass through the highlightIndex attribute for custom components. | ||
if (typeof HighlightTag !== 'string') { | ||
props.highlightIndex = highlightIndex; | ||
} | ||
return (0, _react.createElement)(HighlightTag, props); | ||
} else { | ||
return _react2['default'].createElement( | ||
'span', | ||
{ | ||
className: unhighlightClassName, | ||
key: index, | ||
style: unhighlightStyle | ||
}, | ||
text | ||
); | ||
return (0, _react.createElement)('span', { | ||
children: text, | ||
className: unhighlightClassName, | ||
key: index, | ||
style: unhighlightStyle | ||
}); | ||
} | ||
}) | ||
); | ||
}); | ||
} | ||
@@ -220,0 +218,0 @@ |
@@ -100,4 +100,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _react2 = _interopRequireDefault(_react); | ||
var _memoizeOne = __webpack_require__(15); | ||
@@ -162,3 +160,3 @@ | ||
var HighlightTag = highlightTag; | ||
var highlightCount = -1; | ||
var highlightIndex = -1; | ||
var highlightClassNames = ''; | ||
@@ -176,10 +174,9 @@ var highlightStyles = undefined; | ||
return _react2['default'].createElement( | ||
'span', | ||
{ className: className }, | ||
chunks.map(function (chunk, index) { | ||
return (0, _react.createElement)('span', { | ||
className: className, | ||
children: chunks.map(function (chunk, index) { | ||
var text = textToHighlight.substr(chunk.start, chunk.end - chunk.start); | ||
if (chunk.highlight) { | ||
highlightCount++; | ||
highlightIndex++; | ||
@@ -198,3 +195,3 @@ var highlightClass = undefined; | ||
var isActive = highlightCount === +activeIndex; | ||
var isActive = highlightIndex === +activeIndex; | ||
@@ -204,25 +201,26 @@ highlightClassNames = highlightClass + ' ' + (isActive ? activeClassName : ''); | ||
return _react2['default'].createElement( | ||
HighlightTag, | ||
{ | ||
className: highlightClassNames, | ||
highlightIndex: highlightCount, | ||
key: index, | ||
style: highlightStyles | ||
}, | ||
text | ||
); | ||
var props = { | ||
children: text, | ||
className: highlightClassNames, | ||
key: index, | ||
style: highlightStyles | ||
}; | ||
// Don't attach arbitrary props to DOM elements; this triggers React DEV warnings (https://fb.me/react-unknown-prop) | ||
// Only pass through the highlightIndex attribute for custom components. | ||
if (typeof HighlightTag !== 'string') { | ||
props.highlightIndex = highlightIndex; | ||
} | ||
return (0, _react.createElement)(HighlightTag, props); | ||
} else { | ||
return _react2['default'].createElement( | ||
'span', | ||
{ | ||
className: unhighlightClassName, | ||
key: index, | ||
style: unhighlightStyle | ||
}, | ||
text | ||
); | ||
return (0, _react.createElement)('span', { | ||
children: text, | ||
className: unhighlightClassName, | ||
key: index, | ||
style: unhighlightStyle | ||
}); | ||
} | ||
}) | ||
); | ||
}); | ||
} | ||
@@ -229,0 +227,0 @@ |
{ | ||
"name": "react-highlight-words", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"description": "React component to highlight words within a larger body of text", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2919730
3868