html-react-parser 4.2.4 → 4.2.6

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.
@@ -1014,11 +1014,11 @@
1014
1014
  }
1015
1015
  utilities$4.formatDOM = formatDOM;
1016
1016
 
1017
- var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1017
+ var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1018
1018
  return (mod && mod.__esModule) ? mod : { "default": mod };
1019
1019
  };
1020
1020
  Object.defineProperty(htmlToDom, "__esModule", { value: true });
1021
- var domparser_1 = __importDefault$1(domparser$1);
1021
+ var domparser_1 = __importDefault$2(domparser$1);
1022
1022
  var utilities_1$1 = utilities$4;
1023
1023
  var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
1024
1024
  /**
@@ -1855,9 +1855,9 @@
1855
1855
  lib.isCustomAttribute = isCustomAttribute;
1856
1856
  lib.possibleStandardNames = possibleStandardNames;
1857
1857
 
1858
- var cjs = {};
1858
+ var cjs$1 = {};
1859
1859
 
1860
- var styleToObject = {exports: {}};
1860
+ var cjs = {};
1861
1861
 
1862
1862
  // http://www.w3.org/TR/CSS21/grammar.html
1863
1863
  // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
@@ -1892,7 +1892,7 @@
1892
1892
  * @throws {TypeError}
1893
1893
  * @throws {Error}
1894
1894
  */
1895
- var inlineStyleParser = function(style, options) {
1895
+ var inlineStyleParser = function (style, options) {
1896
1896
  if (typeof style !== 'string') {
1897
1897
  throw new TypeError('First argument must be a string');
1898
1898
  }
@@ -1926,7 +1926,7 @@
1926
1926
  */
1927
1927
  function position() {
1928
1928
  var start = { line: lineno, column: column };
1929
- return function(node) {
1929
+ return function (node) {
1930
1930
  node.position = new Position(start);
1931
1931
  whitespace();
1932
1932
  return node;
@@ -2117,51 +2117,48 @@
2117
2117
  return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
2118
2118
  }
2119
2119
 
2120
- var parse = inlineStyleParser;
2121
-
2120
+ var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2121
+ return (mod && mod.__esModule) ? mod : { "default": mod };
2122
+ };
2123
+ Object.defineProperty(cjs, "__esModule", { value: true });
2124
+ var inline_style_parser_1 = __importDefault$1(inlineStyleParser);
2122
2125
  /**
2123
2126
  * Parses inline style to object.
2124
2127
  *
2125
- * @example
2126
- * // returns { 'line-height': '42' }
2127
- * StyleToObject('line-height: 42;');
2128
+ * @param style - Inline style.
2129
+ * @param iterator - Iterator.
2130
+ * @returns - Style object or null.
2131
+ *
2132
+ * @example Parsing inline style to object:
2128
2133
  *
2129
- * @param {String} style - The inline style.
2130
- * @param {Function} [iterator] - The iterator function.
2131
- * @return {null|Object}
2134
+ * ```js
2135
+ * import parse from 'style-to-object';
2136
+ * parse('line-height: 42;'); // { 'line-height': '42' }
2137
+ * ```
2132
2138
  */
2133
2139
  function StyleToObject(style, iterator) {
2134
- var output = null;
2135
- if (!style || typeof style !== 'string') {
2136
- return output;
2137
- }
2138
-
2139
- var declaration;
2140
- var declarations = parse(style);
2141
- var hasIterator = typeof iterator === 'function';
2142
- var property;
2143
- var value;
2144
-
2145
- for (var i = 0, len = declarations.length; i < len; i++) {
2146
- declaration = declarations[i];
2147
- property = declaration.property;
2148
- value = declaration.value;
2149
-
2150
- if (hasIterator) {
2151
- iterator(property, value, declaration);
2152
- } else if (value) {
2153
- output || (output = {});
2154
- output[property] = value;
2140
+ var styleObject = null;
2141
+ if (!style || typeof style !== 'string') {
2142
+ return styleObject;
2155
2143
  }
2156
- }
2157
-
2158
- return output;
2144
+ var declarations = (0, inline_style_parser_1.default)(style);
2145
+ var hasIterator = typeof iterator === 'function';
2146
+ declarations.forEach(function (declaration) {
2147
+ if (declaration.type !== 'declaration') {
2148
+ return;
2149
+ }
2150
+ var property = declaration.property, value = declaration.value;
2151
+ if (hasIterator) {
2152
+ iterator(property, value, declaration);
2153
+ }
2154
+ else if (value) {
2155
+ styleObject = styleObject || {};
2156
+ styleObject[property] = value;
2157
+ }
2158
+ });
2159
+ return styleObject;
2159
2160
  }
2160
-
2161
- styleToObject.exports = StyleToObject;
2162
- styleToObject.exports.default = StyleToObject; // ESM support
2163
-
2164
- var styleToObjectExports = styleToObject.exports;
2161
+ cjs.default = StyleToObject;
2165
2162
 
2166
2163
  var utilities$3 = {};
2167
2164
 
@@ -2200,8 +2197,8 @@
2200
2197
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2201
2198
  return (mod && mod.__esModule) ? mod : { "default": mod };
2202
2199
  };
2203
- Object.defineProperty(cjs, "__esModule", { value: true });
2204
- var style_to_object_1 = __importDefault(styleToObjectExports);
2200
+ Object.defineProperty(cjs$1, "__esModule", { value: true });
2201
+ var style_to_object_1 = __importDefault(cjs);
2205
2202
  var utilities_1 = utilities$3;
2206
2203
  function StyleToJS(style, options) {
2207
2204
  var output = {};
@@ -2215,10 +2212,10 @@
2215
2212
  });
2216
2213
  return output;
2217
2214
  }
2218
- cjs.default = StyleToJS;
2215
+ cjs$1.default = StyleToJS;
2219
2216
 
2220
2217
  var React$1 = require$$0;
2221
- var styleToJS = cjs.default;
2218
+ var styleToJS = cjs$1.default;
2222
2219
 
2223
2220
  /**
2224
2221
  * Swap key with value in an object.