html-react-parser 1.4.13 → 1.4.14
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/dist/html-react-parser.js +31 -27
- package/dist/html-react-parser.js.map +1 -1
- package/dist/html-react-parser.min.js +1 -1
- package/dist/html-react-parser.min.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +6 -6
- package/lib/attributes-to-props.d.ts +2 -2
- package/lib/attributes-to-props.js +3 -3
- package/lib/dom-to-react.d.ts +3 -3
- package/lib/dom-to-react.js +7 -7
- package/lib/utilities.js +7 -7
- package/package.json +3 -3
|
@@ -1137,6 +1137,7 @@
|
|
|
1137
1137
|
var HYPHEN_REGEX = /-([a-z])/g;
|
|
1138
1138
|
var NO_HYPHEN_REGEX = /^[^-]+$/;
|
|
1139
1139
|
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
|
|
1140
|
+
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
|
|
1140
1141
|
var skipCamelCase = function (property) {
|
|
1141
1142
|
return !property ||
|
|
1142
1143
|
NO_HYPHEN_REGEX.test(property) ||
|
|
@@ -1145,14 +1146,17 @@
|
|
|
1145
1146
|
var capitalize = function (match, character) {
|
|
1146
1147
|
return character.toUpperCase();
|
|
1147
1148
|
};
|
|
1148
|
-
var trimHyphen = function (match, prefix) { return prefix
|
|
1149
|
+
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); };
|
|
1149
1150
|
var camelCase = function (property, options) {
|
|
1150
1151
|
if (options === void 0) { options = {}; }
|
|
1151
1152
|
if (skipCamelCase(property)) {
|
|
1152
1153
|
return property;
|
|
1153
1154
|
}
|
|
1154
1155
|
property = property.toLowerCase();
|
|
1155
|
-
if (
|
|
1156
|
+
if (options.reactCompat) {
|
|
1157
|
+
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1156
1160
|
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
|
|
1157
1161
|
}
|
|
1158
1162
|
return property.replace(HYPHEN_REGEX, capitalize);
|
|
@@ -1171,9 +1175,9 @@
|
|
|
1171
1175
|
if (!style || typeof style !== 'string') {
|
|
1172
1176
|
return output;
|
|
1173
1177
|
}
|
|
1174
|
-
style_to_object_1["default"](style, function (property, value) {
|
|
1178
|
+
(0, style_to_object_1["default"])(style, function (property, value) {
|
|
1175
1179
|
if (property && value) {
|
|
1176
|
-
output[utilities_1.camelCase(property, options)] = value;
|
|
1180
|
+
output[(0, utilities_1.camelCase)(property, options)] = value;
|
|
1177
1181
|
}
|
|
1178
1182
|
});
|
|
1179
1183
|
return output;
|
|
@@ -1187,9 +1191,9 @@
|
|
|
1187
1191
|
/**
|
|
1188
1192
|
* Swap key with value in an object.
|
|
1189
1193
|
*
|
|
1190
|
-
* @param
|
|
1191
|
-
* @param
|
|
1192
|
-
* @
|
|
1194
|
+
* @param {object} obj - The object.
|
|
1195
|
+
* @param {Function} [override] - The override method.
|
|
1196
|
+
* @returns - The inverted object.
|
|
1193
1197
|
*/
|
|
1194
1198
|
function invertObject(obj, override) {
|
|
1195
1199
|
if (!obj || typeof obj !== 'object') {
|
|
@@ -1227,8 +1231,8 @@
|
|
|
1227
1231
|
* @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
|
|
1228
1232
|
*
|
|
1229
1233
|
* @param {string} tagName - The name of the html tag.
|
|
1230
|
-
* @param {
|
|
1231
|
-
* @
|
|
1234
|
+
* @param {object} props - The props being passed to the element.
|
|
1235
|
+
* @returns - Whether tag is custom component.
|
|
1232
1236
|
*/
|
|
1233
1237
|
function isCustomComponent(tagName, props) {
|
|
1234
1238
|
if (tagName.indexOf('-') === -1) {
|
|
@@ -1296,8 +1300,8 @@
|
|
|
1296
1300
|
/**
|
|
1297
1301
|
* Checks if the given node can contain text nodes
|
|
1298
1302
|
*
|
|
1299
|
-
* @param {DomElement} node
|
|
1300
|
-
* @returns
|
|
1303
|
+
* @param {DomElement} node - Node.
|
|
1304
|
+
* @returns - Whether node can contain text nodes.
|
|
1301
1305
|
*/
|
|
1302
1306
|
function canTextBeChildOfNode$1(node) {
|
|
1303
1307
|
return !elementsWithNoTextChildren.has(node.name);
|
|
@@ -1318,8 +1322,8 @@
|
|
|
1318
1322
|
/**
|
|
1319
1323
|
* Converts HTML/SVG DOM attributes to React props.
|
|
1320
1324
|
*
|
|
1321
|
-
* @param
|
|
1322
|
-
* @
|
|
1325
|
+
* @param {object} [attributes={}] - HTML/SVG DOM attributes.
|
|
1326
|
+
* @returns - React props.
|
|
1323
1327
|
*/
|
|
1324
1328
|
var attributesToProps$2 = function attributesToProps(attributes) {
|
|
1325
1329
|
attributes = attributes || {};
|
|
@@ -1393,7 +1397,7 @@
|
|
|
1393
1397
|
* Gets prop name from lowercased attribute name.
|
|
1394
1398
|
*
|
|
1395
1399
|
* @param {string} attributeName - Lowercased attribute name.
|
|
1396
|
-
* @
|
|
1400
|
+
* @returns - Prop name.
|
|
1397
1401
|
*/
|
|
1398
1402
|
function getPropName(attributeName) {
|
|
1399
1403
|
return reactProperty.possibleStandardNames[attributeName];
|
|
@@ -1409,11 +1413,11 @@
|
|
|
1409
1413
|
/**
|
|
1410
1414
|
* Converts DOM nodes to JSX element(s).
|
|
1411
1415
|
*
|
|
1412
|
-
* @param
|
|
1413
|
-
* @param
|
|
1414
|
-
* @param
|
|
1415
|
-
* @param
|
|
1416
|
-
* @
|
|
1416
|
+
* @param {DomElement[]} nodes - DOM nodes.
|
|
1417
|
+
* @param {object} [options={}] - Options.
|
|
1418
|
+
* @param {Function} [options.replace] - Replacer.
|
|
1419
|
+
* @param {object} [options.library] - Library (React, Preact, etc.).
|
|
1420
|
+
* @returns - String or JSX element(s).
|
|
1417
1421
|
*/
|
|
1418
1422
|
function domToReact$1(nodes, options) {
|
|
1419
1423
|
options = options || {};
|
|
@@ -1526,8 +1530,8 @@
|
|
|
1526
1530
|
* Determines whether DOM element attributes should be transformed to props.
|
|
1527
1531
|
* Web Components should not have their attributes transformed except for `style`.
|
|
1528
1532
|
*
|
|
1529
|
-
* @param
|
|
1530
|
-
* @
|
|
1533
|
+
* @param {DomElement} node
|
|
1534
|
+
* @returns - Whether node attributes should be converted to props.
|
|
1531
1535
|
*/
|
|
1532
1536
|
function skipAttributesToProps(node) {
|
|
1533
1537
|
return (
|
|
@@ -2646,12 +2650,12 @@
|
|
|
2646
2650
|
/**
|
|
2647
2651
|
* Converts HTML string to React elements.
|
|
2648
2652
|
*
|
|
2649
|
-
* @param
|
|
2650
|
-
* @param
|
|
2651
|
-
* @param
|
|
2652
|
-
* @param
|
|
2653
|
-
* @param
|
|
2654
|
-
* @
|
|
2653
|
+
* @param {string} html - HTML string.
|
|
2654
|
+
* @param {object} [options] - Parser options.
|
|
2655
|
+
* @param {object} [options.htmlparser2] - htmlparser2 options.
|
|
2656
|
+
* @param {object} [options.library] - Library for React, Preact, etc.
|
|
2657
|
+
* @param {Function} [options.replace] - Replace method.
|
|
2658
|
+
* @returns {JSX.Element|JSX.Element[]|string} - React element(s), empty array, or string.
|
|
2655
2659
|
*/
|
|
2656
2660
|
function HTMLReactParser(html, options) {
|
|
2657
2661
|
if (typeof html !== 'string') {
|