html-react-parser 3.0.10 → 3.0.12
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,6 +1,16 @@
|
|
|
1
1
|
var reactProperty = require('react-property');
|
|
2
2
|
var utilities = require('./utilities');
|
|
3
3
|
|
|
4
|
+
// https://reactjs.org/docs/uncontrolled-components.html
|
|
5
|
+
// https://developer.mozilla.org/docs/Web/HTML/Attributes
|
|
6
|
+
var UNCONTROLLED_COMPONENT_ATTRIBUTES = ['checked', 'value'];
|
|
7
|
+
var UNCONTROLLED_COMPONENT_NAMES = ['input', 'select', 'textarea'];
|
|
8
|
+
|
|
9
|
+
var VALUE_ONLY_INPUTS = {
|
|
10
|
+
reset: true,
|
|
11
|
+
submit: true
|
|
12
|
+
};
|
|
13
|
+
|
|
4
14
|
/**
|
|
5
15
|
* Converts HTML/SVG DOM attributes to React props.
|
|
6
16
|
*
|
|
@@ -11,18 +21,13 @@ var utilities = require('./utilities');
|
|
|
11
21
|
module.exports = function attributesToProps(attributes, nodeName) {
|
|
12
22
|
attributes = attributes || {};
|
|
13
23
|
|
|
14
|
-
var valueOnlyInputs = {
|
|
15
|
-
reset: true,
|
|
16
|
-
submit: true
|
|
17
|
-
};
|
|
18
|
-
|
|
19
24
|
var attributeName;
|
|
20
25
|
var attributeNameLowerCased;
|
|
21
26
|
var attributeValue;
|
|
22
27
|
var propName;
|
|
23
28
|
var propertyInfo;
|
|
24
29
|
var props = {};
|
|
25
|
-
var inputIsValueOnly = attributes.type &&
|
|
30
|
+
var inputIsValueOnly = attributes.type && VALUE_ONLY_INPUTS[attributes.type];
|
|
26
31
|
|
|
27
32
|
for (attributeName in attributes) {
|
|
28
33
|
attributeValue = attributes[attributeName];
|
|
@@ -41,10 +46,9 @@ module.exports = function attributesToProps(attributes, nodeName) {
|
|
|
41
46
|
propertyInfo = reactProperty.getPropertyInfo(propName);
|
|
42
47
|
|
|
43
48
|
// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
|
|
44
|
-
// https://reactjs.org/docs/uncontrolled-components.html
|
|
45
49
|
if (
|
|
46
|
-
(propName
|
|
47
|
-
nodeName !==
|
|
50
|
+
UNCONTROLLED_COMPONENT_ATTRIBUTES.indexOf(propName) !== -1 &&
|
|
51
|
+
UNCONTROLLED_COMPONENT_NAMES.indexOf(nodeName) !== -1 &&
|
|
48
52
|
!inputIsValueOnly
|
|
49
53
|
) {
|
|
50
54
|
propName = getPropName('default' + attributeNameLowerCased);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-react-parser",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"description": "HTML to React parser.",
|
|
5
5
|
"author": "Mark <mark@remarkablemark.org>",
|
|
6
6
|
"main": "index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"domhandler": "5.0.3",
|
|
49
|
-
"html-dom-parser": "3.1.
|
|
49
|
+
"html-dom-parser": "3.1.5",
|
|
50
50
|
"react-property": "2.0.0",
|
|
51
51
|
"style-to-js": "1.1.3"
|
|
52
52
|
},
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"prettier": "2.8.4",
|
|
72
72
|
"react": "18.2.0",
|
|
73
73
|
"react-dom": "18.2.0",
|
|
74
|
-
"rimraf": "4.
|
|
74
|
+
"rimraf": "4.3.0",
|
|
75
75
|
"rollup": "2.79.1",
|
|
76
76
|
"rollup-plugin-terser": "7.0.2",
|
|
77
77
|
"size-limit": "8.1.0",
|