html-react-parser 3.0.5 → 3.0.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.
@@ -10,6 +10,10 @@ export type Props = Record<string, string> & {
10
10
  * Converts HTML/SVG DOM attributes to React props.
11
11
  *
12
12
  * @param attributes - HTML/SVG DOM attributes.
13
+ * @param nodeName - DOM node name.
13
14
  * @returns - React props.
14
15
  */
15
- export default function attributesToProps(attributes: Attributes): Props;
16
+ export default function attributesToProps(
17
+ attributes: Attributes,
18
+ nodeName?: string
19
+ ): Props;
@@ -5,9 +5,10 @@ var utilities = require('./utilities');
5
5
  * Converts HTML/SVG DOM attributes to React props.
6
6
  *
7
7
  * @param {object} [attributes={}] - HTML/SVG DOM attributes.
8
+ * @param {string} [nodeName] - DOM node name.
8
9
  * @returns - React props.
9
10
  */
10
- module.exports = function attributesToProps(attributes) {
11
+ module.exports = function attributesToProps(attributes, nodeName) {
11
12
  attributes = attributes || {};
12
13
 
13
14
  var valueOnlyInputs = {
@@ -43,6 +44,7 @@ module.exports = function attributesToProps(attributes) {
43
44
  // https://reactjs.org/docs/uncontrolled-components.html
44
45
  if (
45
46
  (propName === 'checked' || propName === 'value') &&
47
+ nodeName !== 'option' &&
46
48
  !inputIsValueOnly
47
49
  ) {
48
50
  propName = getPropName('default' + attributeNameLowerCased);
@@ -76,7 +76,7 @@ function domToReact(nodes, options) {
76
76
  if (skipAttributesToProps(node)) {
77
77
  setStyleProp(props.style, props);
78
78
  } else if (props) {
79
- props = attributesToProps(props);
79
+ props = attributesToProps(props, node.name);
80
80
  }
81
81
 
82
82
  children = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-react-parser",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "HTML to React parser.",
5
5
  "author": "Mark <mark@remarkablemark.org>",
6
6
  "main": "index.js",
@@ -47,21 +47,21 @@
47
47
  "domhandler": "5.0.3",
48
48
  "html-dom-parser": "3.1.2",
49
49
  "react-property": "2.0.0",
50
- "style-to-js": "1.1.1"
50
+ "style-to-js": "1.1.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@commitlint/cli": "17.3.0",
54
- "@commitlint/config-conventional": "17.3.0",
53
+ "@commitlint/cli": "17.4.0",
54
+ "@commitlint/config-conventional": "17.4.0",
55
55
  "@rollup/plugin-commonjs": "24.0.0",
56
56
  "@rollup/plugin-node-resolve": "15.0.1",
57
57
  "@size-limit/preset-big-lib": "8.1.0",
58
58
  "@types/react": "18.0.26",
59
- "@typescript-eslint/parser": "5.47.0",
59
+ "@typescript-eslint/parser": "5.48.0",
60
60
  "benchmark": "2.1.4",
61
61
  "dtslint": "4.2.1",
62
- "eslint": "8.30.0",
62
+ "eslint": "8.31.0",
63
63
  "eslint-plugin-prettier": "4.2.1",
64
- "husky": "8.0.2",
64
+ "husky": "8.0.3",
65
65
  "jest": "29.3.1",
66
66
  "jest-environment-jsdom": "29.3.1",
67
67
  "lint-staged": "13.1.0",