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.
|
@@ -994,6 +994,7 @@
|
|
|
994
994
|
function formatDOM$1(nodes, parent, directive) {
|
|
995
995
|
parent = parent || null;
|
|
996
996
|
var result = [];
|
|
997
|
+
var tagName;
|
|
997
998
|
|
|
998
999
|
for (var index = 0, len = nodes.length; index < len; index++) {
|
|
999
1000
|
var node = nodes[index];
|
|
@@ -1002,14 +1003,12 @@
|
|
|
1002
1003
|
// set the node data given the type
|
|
1003
1004
|
switch (node.nodeType) {
|
|
1004
1005
|
case 1:
|
|
1006
|
+
tagName = formatTagName(node.nodeName);
|
|
1005
1007
|
// script, style, or tag
|
|
1006
|
-
current = new Element(
|
|
1007
|
-
formatTagName(node.nodeName),
|
|
1008
|
-
formatAttributes(node.attributes)
|
|
1009
|
-
);
|
|
1008
|
+
current = new Element(tagName, formatAttributes(node.attributes));
|
|
1010
1009
|
current.children = formatDOM$1(
|
|
1011
1010
|
// template children are on content
|
|
1012
|
-
|
|
1011
|
+
tagName === 'template' ? node.content.childNodes : node.childNodes,
|
|
1013
1012
|
current
|
|
1014
1013
|
);
|
|
1015
1014
|
break;
|
|
@@ -2409,6 +2408,16 @@
|
|
|
2409
2408
|
var reactProperty = lib;
|
|
2410
2409
|
var utilities$1 = utilities$2;
|
|
2411
2410
|
|
|
2411
|
+
// https://reactjs.org/docs/uncontrolled-components.html
|
|
2412
|
+
// https://developer.mozilla.org/docs/Web/HTML/Attributes
|
|
2413
|
+
var UNCONTROLLED_COMPONENT_ATTRIBUTES = ['checked', 'value'];
|
|
2414
|
+
var UNCONTROLLED_COMPONENT_NAMES = ['input', 'select', 'textarea'];
|
|
2415
|
+
|
|
2416
|
+
var VALUE_ONLY_INPUTS = {
|
|
2417
|
+
reset: true,
|
|
2418
|
+
submit: true
|
|
2419
|
+
};
|
|
2420
|
+
|
|
2412
2421
|
/**
|
|
2413
2422
|
* Converts HTML/SVG DOM attributes to React props.
|
|
2414
2423
|
*
|
|
@@ -2419,18 +2428,13 @@
|
|
|
2419
2428
|
var attributesToProps$2 = function attributesToProps(attributes, nodeName) {
|
|
2420
2429
|
attributes = attributes || {};
|
|
2421
2430
|
|
|
2422
|
-
var valueOnlyInputs = {
|
|
2423
|
-
reset: true,
|
|
2424
|
-
submit: true
|
|
2425
|
-
};
|
|
2426
|
-
|
|
2427
2431
|
var attributeName;
|
|
2428
2432
|
var attributeNameLowerCased;
|
|
2429
2433
|
var attributeValue;
|
|
2430
2434
|
var propName;
|
|
2431
2435
|
var propertyInfo;
|
|
2432
2436
|
var props = {};
|
|
2433
|
-
var inputIsValueOnly = attributes.type &&
|
|
2437
|
+
var inputIsValueOnly = attributes.type && VALUE_ONLY_INPUTS[attributes.type];
|
|
2434
2438
|
|
|
2435
2439
|
for (attributeName in attributes) {
|
|
2436
2440
|
attributeValue = attributes[attributeName];
|
|
@@ -2449,10 +2453,9 @@
|
|
|
2449
2453
|
propertyInfo = reactProperty.getPropertyInfo(propName);
|
|
2450
2454
|
|
|
2451
2455
|
// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
|
|
2452
|
-
// https://reactjs.org/docs/uncontrolled-components.html
|
|
2453
2456
|
if (
|
|
2454
|
-
(propName
|
|
2455
|
-
nodeName !==
|
|
2457
|
+
UNCONTROLLED_COMPONENT_ATTRIBUTES.indexOf(propName) !== -1 &&
|
|
2458
|
+
UNCONTROLLED_COMPONENT_NAMES.indexOf(nodeName) !== -1 &&
|
|
2456
2459
|
!inputIsValueOnly
|
|
2457
2460
|
) {
|
|
2458
2461
|
propName = getPropName('default' + attributeNameLowerCased);
|