html-react-parser 5.1.0 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/html-react-parser.js +5 -4
- package/dist/html-react-parser.js.map +1 -1
- package/dist/html-react-parser.min.js +1 -1
- package/dist/html-react-parser.min.js.map +1 -1
- package/lib/dom-to-react.d.ts.map +1 -1
- package/lib/dom-to-react.js +5 -4
- package/lib/dom-to-react.js.map +1 -1
- package/lib/types.d.ts +2 -2
- package/lib/types.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/dom-to-react.ts +5 -5
- package/src/types.ts +6 -2
package/README.md
CHANGED
|
@@ -207,7 +207,7 @@ parse('<br>', {
|
|
|
207
207
|
```
|
|
208
208
|
|
|
209
209
|
> [!NOTE]
|
|
210
|
-
> The index will restart at 0 when traversing the node's children so don't rely on index being a unique key.
|
|
210
|
+
> The index will restart at 0 when traversing the node's children so don't rely on index being a unique key. See [#1259](https://github.com/remarkablemark/html-react-parser/issues/1259#issuecomment-1889574133).
|
|
211
211
|
|
|
212
212
|
#### replace with TypeScript
|
|
213
213
|
|
|
@@ -2657,10 +2657,11 @@
|
|
|
2657
2657
|
* @returns - String or JSX element(s).
|
|
2658
2658
|
*/
|
|
2659
2659
|
function domToReact(nodes, options) {
|
|
2660
|
+
if (options === void 0) { options = {}; }
|
|
2660
2661
|
var reactElements = [];
|
|
2661
|
-
var hasReplace = typeof
|
|
2662
|
-
var transform =
|
|
2663
|
-
var _a =
|
|
2662
|
+
var hasReplace = typeof options.replace === 'function';
|
|
2663
|
+
var transform = options.transform || utilities_1.returnFirstArg;
|
|
2664
|
+
var _a = options.library || React, cloneElement = _a.cloneElement, createElement = _a.createElement, isValidElement = _a.isValidElement;
|
|
2664
2665
|
var nodesLength = nodes.length;
|
|
2665
2666
|
for (var index = 0; index < nodesLength; index++) {
|
|
2666
2667
|
var node = nodes[index];
|
|
@@ -2690,7 +2691,7 @@
|
|
|
2690
2691
|
}
|
|
2691
2692
|
// Trim is enabled and we have a whitespace node
|
|
2692
2693
|
// so skip it
|
|
2693
|
-
if (
|
|
2694
|
+
if (options.trim && isWhitespace) {
|
|
2694
2695
|
continue;
|
|
2695
2696
|
}
|
|
2696
2697
|
// We have a text node that's not whitespace and it can be nested
|