html-react-parser 5.2.6 → 5.2.7
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
CHANGED
|
@@ -27,7 +27,7 @@ import parse from 'html-react-parser';
|
|
|
27
27
|
parse('<p>Hello, World!</p>'); // React.createElement('p', {}, 'Hello, World!')
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
[
|
|
30
|
+
[StackBlitz](https://stackblitz.com/edit/html-react-parser) | [TypeScript](https://stackblitz.com/edit/html-react-parser-typescript) | [JSFiddle](https://jsfiddle.net/remarkablemark/7v86d800/) | [Examples](https://github.com/remarkablemark/html-react-parser/tree/master/examples)
|
|
31
31
|
|
|
32
32
|
<details>
|
|
33
33
|
<summary>Table of Contents</summary>
|
|
@@ -207,6 +207,7 @@ parse('<br>', {
|
|
|
207
207
|
```
|
|
208
208
|
|
|
209
209
|
> [!NOTE]
|
|
210
|
+
>
|
|
210
211
|
> 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
212
|
|
|
212
213
|
#### replace with TypeScript
|
|
@@ -401,7 +402,8 @@ parse('<br>', {
|
|
|
401
402
|
### htmlparser2
|
|
402
403
|
|
|
403
404
|
> [!WARNING]
|
|
404
|
-
>
|
|
405
|
+
>
|
|
406
|
+
> `htmlparser2` options _**do not work** on the client-side_ (browser); they _**only work** on the server-side_ (Node.js). By overriding the options, it can break universal rendering.
|
|
405
407
|
|
|
406
408
|
Default [htmlparser2 options](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode) can be overridden in >=[0.12.0](https://github.com/remarkablemark/html-react-parser/tree/v0.12.0).
|
|
407
409
|
|
|
@@ -549,6 +551,7 @@ parse('<CustomElement>', options); // React.createElement('CustomElement')
|
|
|
549
551
|
```
|
|
550
552
|
|
|
551
553
|
> [!WARNING]
|
|
554
|
+
>
|
|
552
555
|
> By preserving case-sensitivity of the tags, you may get rendering warnings like:
|
|
553
556
|
>
|
|
554
557
|
> ```
|
|
@@ -2448,7 +2448,7 @@
|
|
|
2448
2448
|
};
|
|
2449
2449
|
Object.defineProperty(cjs$1, "__esModule", { value: true });
|
|
2450
2450
|
cjs$1.default = StyleToObject;
|
|
2451
|
-
|
|
2451
|
+
const inline_style_parser_1 = __importDefault(requireInlineStyleParser());
|
|
2452
2452
|
/**
|
|
2453
2453
|
* Parses inline style to object.
|
|
2454
2454
|
*
|
|
@@ -2464,17 +2464,17 @@
|
|
|
2464
2464
|
* ```
|
|
2465
2465
|
*/
|
|
2466
2466
|
function StyleToObject(style, iterator) {
|
|
2467
|
-
|
|
2467
|
+
let styleObject = null;
|
|
2468
2468
|
if (!style || typeof style !== 'string') {
|
|
2469
2469
|
return styleObject;
|
|
2470
2470
|
}
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
declarations.forEach(
|
|
2471
|
+
const declarations = (0, inline_style_parser_1.default)(style);
|
|
2472
|
+
const hasIterator = typeof iterator === 'function';
|
|
2473
|
+
declarations.forEach((declaration) => {
|
|
2474
2474
|
if (declaration.type !== 'declaration') {
|
|
2475
2475
|
return;
|
|
2476
2476
|
}
|
|
2477
|
-
|
|
2477
|
+
const { property, value } = declaration;
|
|
2478
2478
|
if (hasIterator) {
|
|
2479
2479
|
iterator(property, value, declaration);
|
|
2480
2480
|
}
|