html-react-parser 5.0.2 → 5.0.4

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.
@@ -1,3 +1,3 @@
1
1
  import attributesToProps from '../lib/attributes-to-props.js';
2
2
 
3
- export default attributesToProps.default;
3
+ export default attributesToProps.default || attributesToProps;
@@ -1,3 +1,3 @@
1
1
  import domToReact from '../lib/dom-to-react.js';
2
2
 
3
- export default domToReact.default;
3
+ export default domToReact.default || domToReact;
package/esm/index.mjs CHANGED
@@ -10,4 +10,4 @@ export {
10
10
  htmlToDOM,
11
11
  } from '../lib/index.js';
12
12
 
13
- export default HTMLReactParser.default;
13
+ export default HTMLReactParser.default || HTMLReactParser;
@@ -1,10 +1,15 @@
1
- export type Attributes = Record<string, string>;
2
- export type Props = Record<string, string | boolean> & {
1
+ declare const valueOnlyInputs: {
2
+ readonly reset: true;
3
+ readonly submit: true;
4
+ };
5
+ export type ValueOnlyInputsKeys = keyof typeof valueOnlyInputs;
6
+ export type Attributes = Record<PropertyKey, string>;
7
+ export type Props = Record<PropertyKey, string | boolean> & {
3
8
  dangerouslySetInnerHTML?: {
4
9
  __html: string;
5
10
  };
6
11
  key?: string | number;
7
- style?: Record<string, string>;
12
+ style?: Record<PropertyKey, string>;
8
13
  };
9
14
  /**
10
15
  * Converts HTML/SVG DOM attributes to React props.
@@ -14,4 +19,5 @@ export type Props = Record<string, string | boolean> & {
14
19
  * @returns - React props.
15
20
  */
16
21
  export default function attributesToProps(attributes?: Attributes, nodeName?: string): Props;
22
+ export {};
17
23
  //# sourceMappingURL=attributes-to-props.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attributes-to-props.d.ts","sourceRoot":"","sources":["../src/attributes-to-props.ts"],"names":[],"mappings":"AAwBA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEhD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IACrD,uBAAuB,CAAC,EAAE;QACxB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,UAAU,GAAE,UAAe,EAC3B,QAAQ,CAAC,EAAE,MAAM,GAChB,KAAK,CA8DP"}
1
+ {"version":3,"file":"attributes-to-props.d.ts","sourceRoot":"","sources":["../src/attributes-to-props.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,eAAe;;;CAGX,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,eAAe,CAAC;AAE/D,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAErD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IAC1D,uBAAuB,CAAC,EAAE;QACxB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,UAAU,GAAE,UAAe,EAC3B,QAAQ,CAAC,EAAE,MAAM,GAChB,KAAK,CA6DP"}
@@ -20,8 +20,7 @@ var valueOnlyInputs = {
20
20
  function attributesToProps(attributes, nodeName) {
21
21
  if (attributes === void 0) { attributes = {}; }
22
22
  var props = {};
23
- var isInputValueOnly = Boolean(attributes.type &&
24
- valueOnlyInputs[attributes.type]);
23
+ var isInputValueOnly = Boolean(attributes.type && valueOnlyInputs[attributes.type]);
25
24
  for (var attributeName in attributes) {
26
25
  var attributeValue = attributes[attributeName];
27
26
  // ARIA (aria-*) or custom data (data-*) attribute
@@ -1 +1 @@
1
- {"version":3,"file":"attributes-to-props.js","sourceRoot":"","sources":["../src/attributes-to-props.ts"],"names":[],"mappings":";;AAAA,iDAMwB;AACxB,yCAAuE;AAEvE,kGAAkG;AAClG,yDAAyD;AACzD,IAAM,iCAAiC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAU,CAAC;AACxE,IAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AAO9E,IAAM,eAAe,GAAG;IACtB,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;CACJ,CAAC;AAYX;;;;;;GAMG;AACH,SAAwB,iBAAiB,CACvC,UAA2B,EAC3B,QAAiB;IADjB,2BAAA,EAAA,eAA2B;IAG3B,IAAM,KAAK,GAAU,EAAE,CAAC;IAExB,IAAM,gBAAgB,GAAG,OAAO,CAC9B,UAAU,CAAC,IAAI;QACb,eAAe,CAAC,UAAU,CAAC,IAAoC,CAAC,CACnE,CAAC;IAEF,KAAK,IAAM,aAAa,IAAI,UAAU,EAAE;QACtC,IAAM,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;QAEjD,kDAAkD;QAClD,IAAI,IAAA,kCAAiB,EAAC,aAAa,CAAC,EAAE;YACpC,KAAK,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC;YACtC,SAAS;SACV;QAED,2CAA2C;QAC3C,IAAM,uBAAuB,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAC5D,IAAI,QAAQ,GAAG,WAAW,CAAC,uBAAuB,CAAC,CAAC;QAEpD,IAAI,QAAQ,EAAE;YACZ,IAAM,YAAY,GAAG,IAAA,gCAAe,EAAC,QAAQ,CAAC,CAAC;YAE/C,qFAAqF;YACrF,IACE,iCAAiC,CAAC,OAAO,CACvC,QAA2C,CAC5C,KAAK,CAAC,CAAC;gBACR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AC1C,IAAI,sCAA0B,EAAE;YAC9B,KAAK,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC;SACvC;KACF;IAED,mCAAmC;IACnC,IAAA,wBAAY,EAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC;AACf,CAAC;AAhED,oCAgEC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,aAAqB;IACxC,OAAO,sCAAqB,CAAC,aAAa,CAAC,CAAC;AAC9C,CAAC"}
@@ -9,7 +9,7 @@ import type { Props } from './attributes-to-props';
9
9
  * @param props - Props passed to the element.
10
10
  * @returns - Whether the tag is custom component.
11
11
  */
12
- export declare function isCustomComponent(tagName: string, props?: Record<string, any>): boolean;
12
+ export declare function isCustomComponent(tagName: string, props?: Record<PropertyKey, any>): boolean;
13
13
  /**
14
14
  * Sets style prop.
15
15
  *
@@ -24,7 +24,7 @@ export declare const PRESERVE_CUSTOM_ATTRIBUTES: boolean;
24
24
  /**
25
25
  * @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
26
26
  */
27
- export declare const ELEMENTS_WITH_NO_TEXT_CHILDREN: Set<string>;
27
+ export declare const ELEMENTS_WITH_NO_TEXT_CHILDREN: Set<"colgroup" | "head" | "html" | "table" | "tbody" | "tfoot" | "thead" | "tr" | "frameset">;
28
28
  /**
29
29
  * Checks if the given node can contain text nodes
30
30
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAanD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,OAAO,CAcT;AAMD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAe9D;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,SAAsC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,8BAA8B,aAUzC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,SAAU,OAAO,YACF,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAS,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAgBnD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,GAC/B,OAAO,CAcT;AAMD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAe9D;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,SAAsC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,8BAA8B,+FAUhC,CAAC;AAKZ;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,SAAU,OAAO,YAC4B,CAAC;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAS,GAAG,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAgC;AAChC,4DAAoC;AAKpC,IAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC;IAC3C,gBAAgB;IAChB,eAAe;IACf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CAAC,KAAK,CAAC,IAAI,EAAE,EAAE;QACjB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;QACjB,OAAO;KACR;IAED,IAAI;QACF,KAAK,CAAC,KAAK,GAAG,IAAA,qBAAS,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;KAC9C;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;KAClB;AACH,CAAC;AAfD,oCAeC;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,MAAM,CAAC,eAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAE9E;;GAEG;AACU,QAAA,8BAA8B,GAAG,IAAI,GAAG,CAAC;IACpD,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,OAAO;IACP,MAAM;IACN,MAAM;IACN,UAAU;CACF,CAAC,CAAC;AAKZ;;;;;GAKG;AACI,IAAM,oBAAoB,GAAG,UAAC,IAAa;IAChD,OAAA,CAAC,sCAA8B,CAAC,GAAG,CAAC,IAAI,CAAC,IAAkC,CAAC;AAA5E,CAA4E,CAAC;AADlE,QAAA,oBAAoB,wBAC8C;AAE/E;;;;;GAKG;AACI,IAAM,cAAc,GAAG,UAAC,GAAQ,IAAK,OAAA,GAAG,EAAH,CAAG,CAAC;AAAnC,QAAA,cAAc,kBAAqB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-react-parser",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "HTML to React parser.",
5
5
  "author": "Mark <mark@remarkablemark.org>",
6
6
  "main": "./lib/index.js",
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "domhandler": "5.0.3",
56
- "html-dom-parser": "5.0.3",
56
+ "html-dom-parser": "5.0.4",
57
57
  "react-property": "2.0.2",
58
58
  "style-to-js": "1.1.8"
59
59
  },
@@ -66,11 +66,11 @@
66
66
  "@rollup/plugin-typescript": "11.1.5",
67
67
  "@size-limit/preset-big-lib": "10.0.1",
68
68
  "@types/benchmark": "2.1.4",
69
- "@types/jest": "29.5.6",
69
+ "@types/jest": "29.5.7",
70
70
  "@types/react": "18.2.33",
71
71
  "@types/react-dom": "18.2.14",
72
- "@typescript-eslint/eslint-plugin": "6.9.0",
73
- "@typescript-eslint/parser": "6.9.0",
72
+ "@typescript-eslint/eslint-plugin": "6.9.1",
73
+ "@typescript-eslint/parser": "6.9.1",
74
74
  "benchmark": "2.1.4",
75
75
  "eslint": "8.52.0",
76
76
  "eslint-plugin-prettier": "5.0.1",
@@ -82,7 +82,7 @@
82
82
  "preact": "10.18.1",
83
83
  "react": "18.2.0",
84
84
  "react-dom": "18.2.0",
85
- "rollup": "4.1.5",
85
+ "rollup": "4.2.0",
86
86
  "size-limit": "10.0.1",
87
87
  "ts-jest": "29.1.1",
88
88
  "typescript": "5.2.2"
@@ -22,14 +22,16 @@ const valueOnlyInputs = {
22
22
  submit: true,
23
23
  } as const;
24
24
 
25
- export type Attributes = Record<string, string>;
25
+ export type ValueOnlyInputsKeys = keyof typeof valueOnlyInputs;
26
26
 
27
- export type Props = Record<string, string | boolean> & {
27
+ export type Attributes = Record<PropertyKey, string>;
28
+
29
+ export type Props = Record<PropertyKey, string | boolean> & {
28
30
  dangerouslySetInnerHTML?: {
29
31
  __html: string;
30
32
  };
31
33
  key?: string | number;
32
- style?: Record<string, string>;
34
+ style?: Record<PropertyKey, string>;
33
35
  };
34
36
 
35
37
  /**
@@ -46,8 +48,7 @@ export default function attributesToProps(
46
48
  const props: Props = {};
47
49
 
48
50
  const isInputValueOnly = Boolean(
49
- attributes.type &&
50
- valueOnlyInputs[attributes.type as keyof typeof valueOnlyInputs],
51
+ attributes.type && valueOnlyInputs[attributes.type as ValueOnlyInputsKeys],
51
52
  );
52
53
 
53
54
  for (const attributeName in attributes) {
package/src/utilities.ts CHANGED
@@ -13,7 +13,10 @@ const RESERVED_SVG_MATHML_ELEMENTS = new Set([
13
13
  'font-face-format',
14
14
  'font-face-name',
15
15
  'missing-glyph',
16
- ]);
16
+ ] as const);
17
+
18
+ type ReservedSvgMathmlElements =
19
+ typeof RESERVED_SVG_MATHML_ELEMENTS extends Set<infer T> ? T : never;
17
20
 
18
21
  /**
19
22
  * Check if a tag is a custom component.
@@ -26,7 +29,7 @@ const RESERVED_SVG_MATHML_ELEMENTS = new Set([
26
29
  */
27
30
  export function isCustomComponent(
28
31
  tagName: string,
29
- props?: Record<string, any>,
32
+ props?: Record<PropertyKey, any>,
30
33
  ): boolean {
31
34
  if (tagName.indexOf('-') === -1) {
32
35
  return Boolean(props && typeof props.is === 'string');
@@ -36,7 +39,7 @@ export function isCustomComponent(
36
39
  // We don't mind this whitelist too much because we expect it to never grow.
37
40
  // The alternative is to track the namespace in a few places which is convoluted.
38
41
  // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
39
- if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) {
42
+ if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName as ReservedSvgMathmlElements)) {
40
43
  return false;
41
44
  }
42
45
 
@@ -88,7 +91,10 @@ export const ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
88
91
  'head',
89
92
  'html',
90
93
  'frameset',
91
- ]);
94
+ ] as const);
95
+
96
+ type ElementsWithNoTextChildren =
97
+ typeof ELEMENTS_WITH_NO_TEXT_CHILDREN extends Set<infer T> ? T : never;
92
98
 
93
99
  /**
94
100
  * Checks if the given node can contain text nodes
@@ -97,7 +103,7 @@ export const ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
97
103
  * @returns - Whether the node can contain text nodes.
98
104
  */
99
105
  export const canTextBeChildOfNode = (node: Element) =>
100
- !ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
106
+ !ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name as ElementsWithNoTextChildren);
101
107
 
102
108
  /**
103
109
  * Returns the first argument as is.