html-react-parser
Advanced tools
Comparing version 0.4.0 to 0.4.1
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
The format is based on [Keep a Changelog](http://keepachangelog.com) | ||
and this project adheres to [Semantic Versioning](http://semver.org). | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
<a name="0.4.1"></a> | ||
## [0.4.1](https://github.com/remarkablemark/html-react-parser/compare/v0.4.0...v0.4.1) (2017-11-28) | ||
### Bug Fixes | ||
* **attributes-to-props.js:** Remove unappropriate console logging and remove double quote from tests ([10ff149](https://github.com/remarkablemark/html-react-parser/commit/10ff149)) | ||
* **attributes-to-props.js:** Use AST to transform style attributes into an style object ([68cd565](https://github.com/remarkablemark/html-react-parser/commit/68cd565)) | ||
* **utilities.js:** Format string to lowercase before converting to camel case and assert the string is a string ([4522666](https://github.com/remarkablemark/html-react-parser/commit/4522666)) | ||
## [0.4.0](https://github.com/remarkablemark/html-react-parser/compare/v0.3.6...v0.4.0) - 2017-10-01 | ||
@@ -8,0 +18,0 @@ ### Added |
@@ -83,2 +83,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _hyphenPattern = /-(.)/g; | ||
/** | ||
@@ -91,19 +93,11 @@ * Convert a string to camel case. | ||
function camelCase(string) { | ||
if (typeof string !== 'string') { | ||
if (typeof string !== 'string') { // null is an object | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
// hyphen found after first character | ||
if (string.indexOf('-') > 0) { | ||
var strings = string.toLowerCase().split('-'); | ||
// capitalize starting from the second string item | ||
for (var i = 1, len = strings.length; i < len; i++) { | ||
strings[i] = strings[i].charAt(0).toUpperCase() + strings[i].slice(1); | ||
} | ||
return strings.join(''); | ||
if(string.indexOf('-') < 0) { | ||
return string; | ||
} | ||
return string; | ||
return string.toLowerCase().replace(_hyphenPattern, function(_, character) { | ||
return character.toUpperCase(); | ||
}); | ||
} | ||
@@ -310,3 +304,3 @@ | ||
var domToReact = __webpack_require__(3); | ||
var htmlToDOM = __webpack_require__(12); | ||
var htmlToDOM = __webpack_require__(14); | ||
@@ -463,2 +457,3 @@ // decode HTML entities by default for `htmlparser2` | ||
var propertyConfig = __webpack_require__(6); | ||
var styleToObject = __webpack_require__(12); | ||
var config = propertyConfig.config; | ||
@@ -522,29 +517,12 @@ var isCustomAttribute = propertyConfig.HTMLDOMPropertyConfig.isCustomAttribute; | ||
var result = {}; | ||
// e.g., `color: #f00` | ||
var declarations = style.split(';'); | ||
// css property itemized as key and value | ||
var properties; | ||
var j; | ||
var propertiesLen; | ||
var styleObj = {}; | ||
for (var i = 0, declarationsLen = declarations.length; i < declarationsLen; i++) { | ||
properties = declarations[i].trim().split(':'); | ||
// skip if not a css property | ||
if (properties.length !== 2) { continue; } | ||
// css property name | ||
properties[0] = properties[0].trim(); | ||
// css property value | ||
properties[1] = properties[1].trim(); | ||
if (properties[0] && properties[1]) { | ||
for (j = 0, propertiesLen = properties.length; j < propertiesLen; j++) { | ||
result[utilities.camelCase(properties[0])] = properties[1]; | ||
} | ||
styleToObject(style, function(propName, propValue) { | ||
// Check if it's not a comment node | ||
if (propName && propValue) { | ||
styleObj[utilities.camelCase(propName)] = propValue; | ||
} | ||
} | ||
}); | ||
return result; | ||
return styleObj; | ||
} | ||
@@ -1491,2 +1469,652 @@ | ||
var parse = __webpack_require__(13); | ||
/** | ||
* Parses inline style. | ||
* | ||
* Example: 'color:red' => { color: 'red' } | ||
* | ||
* @param {String} style - The inline style. | ||
* @param {Function} [iterator] - The iterator function. | ||
* @return {null|Object} | ||
*/ | ||
module.exports = function parseInlineStyle(style, iterator) { | ||
if (!style || typeof style !== 'string') return null; | ||
// make sure to wrap declarations in placeholder | ||
var declarations = parse('p{' + style + '}').stylesheet.rules[0].declarations; | ||
var declaration, property, value; | ||
var output = null; | ||
var hasIterator = typeof iterator === 'function'; | ||
for (var i = 0, len = declarations.length; i < len; i++) { | ||
declaration = declarations[i]; | ||
property = declaration.property; | ||
value = declaration.value; | ||
if (hasIterator) { | ||
iterator(property, value, declaration); | ||
} else if (value) { | ||
output || (output = {}); | ||
output[property] = value; | ||
} | ||
} | ||
return output; | ||
}; | ||
/***/ }), | ||
/* 13 */ | ||
/***/ (function(module, exports) { | ||
// http://www.w3.org/TR/CSS21/grammar.html | ||
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 | ||
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g | ||
module.exports = function(css, options){ | ||
options = options || {}; | ||
/** | ||
* Positional. | ||
*/ | ||
var lineno = 1; | ||
var column = 1; | ||
/** | ||
* Update lineno and column based on `str`. | ||
*/ | ||
function updatePosition(str) { | ||
var lines = str.match(/\n/g); | ||
if (lines) lineno += lines.length; | ||
var i = str.lastIndexOf('\n'); | ||
column = ~i ? str.length - i : column + str.length; | ||
} | ||
/** | ||
* Mark position and patch `node.position`. | ||
*/ | ||
function position() { | ||
var start = { line: lineno, column: column }; | ||
return function(node){ | ||
node.position = new Position(start); | ||
whitespace(); | ||
return node; | ||
}; | ||
} | ||
/** | ||
* Store position information for a node | ||
*/ | ||
function Position(start) { | ||
this.start = start; | ||
this.end = { line: lineno, column: column }; | ||
this.source = options.source; | ||
} | ||
/** | ||
* Non-enumerable source string | ||
*/ | ||
Position.prototype.content = css; | ||
/** | ||
* Error `msg`. | ||
*/ | ||
var errorsList = []; | ||
function error(msg) { | ||
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg); | ||
err.reason = msg; | ||
err.filename = options.source; | ||
err.line = lineno; | ||
err.column = column; | ||
err.source = css; | ||
if (options.silent) { | ||
errorsList.push(err); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
/** | ||
* Parse stylesheet. | ||
*/ | ||
function stylesheet() { | ||
var rulesList = rules(); | ||
return { | ||
type: 'stylesheet', | ||
stylesheet: { | ||
rules: rulesList, | ||
parsingErrors: errorsList | ||
} | ||
}; | ||
} | ||
/** | ||
* Opening brace. | ||
*/ | ||
function open() { | ||
return match(/^{\s*/); | ||
} | ||
/** | ||
* Closing brace. | ||
*/ | ||
function close() { | ||
return match(/^}/); | ||
} | ||
/** | ||
* Parse ruleset. | ||
*/ | ||
function rules() { | ||
var node; | ||
var rules = []; | ||
whitespace(); | ||
comments(rules); | ||
while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) { | ||
if (node !== false) { | ||
rules.push(node); | ||
comments(rules); | ||
} | ||
} | ||
return rules; | ||
} | ||
/** | ||
* Match `re` and return captures. | ||
*/ | ||
function match(re) { | ||
var m = re.exec(css); | ||
if (!m) return; | ||
var str = m[0]; | ||
updatePosition(str); | ||
css = css.slice(str.length); | ||
return m; | ||
} | ||
/** | ||
* Parse whitespace. | ||
*/ | ||
function whitespace() { | ||
match(/^\s*/); | ||
} | ||
/** | ||
* Parse comments; | ||
*/ | ||
function comments(rules) { | ||
var c; | ||
rules = rules || []; | ||
while (c = comment()) { | ||
if (c !== false) { | ||
rules.push(c); | ||
} | ||
} | ||
return rules; | ||
} | ||
/** | ||
* Parse comment. | ||
*/ | ||
function comment() { | ||
var pos = position(); | ||
if ('/' != css.charAt(0) || '*' != css.charAt(1)) return; | ||
var i = 2; | ||
while ("" != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) ++i; | ||
i += 2; | ||
if ("" === css.charAt(i-1)) { | ||
return error('End of comment missing'); | ||
} | ||
var str = css.slice(2, i - 2); | ||
column += 2; | ||
updatePosition(str); | ||
css = css.slice(i); | ||
column += 2; | ||
return pos({ | ||
type: 'comment', | ||
comment: str | ||
}); | ||
} | ||
/** | ||
* Parse selector. | ||
*/ | ||
function selector() { | ||
var m = match(/^([^{]+)/); | ||
if (!m) return; | ||
/* @fix Remove all comments from selectors | ||
* http://ostermiller.org/findcomment.html */ | ||
return trim(m[0]) | ||
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '') | ||
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m) { | ||
return m.replace(/,/g, '\u200C'); | ||
}) | ||
.split(/\s*(?![^(]*\)),\s*/) | ||
.map(function(s) { | ||
return s.replace(/\u200C/g, ','); | ||
}); | ||
} | ||
/** | ||
* Parse declaration. | ||
*/ | ||
function declaration() { | ||
var pos = position(); | ||
// prop | ||
var prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); | ||
if (!prop) return; | ||
prop = trim(prop[0]); | ||
// : | ||
if (!match(/^:\s*/)) return error("property missing ':'"); | ||
// val | ||
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); | ||
var ret = pos({ | ||
type: 'declaration', | ||
property: prop.replace(commentre, ''), | ||
value: val ? trim(val[0]).replace(commentre, '') : '' | ||
}); | ||
// ; | ||
match(/^[;\s]*/); | ||
return ret; | ||
} | ||
/** | ||
* Parse declarations. | ||
*/ | ||
function declarations() { | ||
var decls = []; | ||
if (!open()) return error("missing '{'"); | ||
comments(decls); | ||
// declarations | ||
var decl; | ||
while (decl = declaration()) { | ||
if (decl !== false) { | ||
decls.push(decl); | ||
comments(decls); | ||
} | ||
} | ||
if (!close()) return error("missing '}'"); | ||
return decls; | ||
} | ||
/** | ||
* Parse keyframe. | ||
*/ | ||
function keyframe() { | ||
var m; | ||
var vals = []; | ||
var pos = position(); | ||
while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) { | ||
vals.push(m[1]); | ||
match(/^,\s*/); | ||
} | ||
if (!vals.length) return; | ||
return pos({ | ||
type: 'keyframe', | ||
values: vals, | ||
declarations: declarations() | ||
}); | ||
} | ||
/** | ||
* Parse keyframes. | ||
*/ | ||
function atkeyframes() { | ||
var pos = position(); | ||
var m = match(/^@([-\w]+)?keyframes\s*/); | ||
if (!m) return; | ||
var vendor = m[1]; | ||
// identifier | ||
var m = match(/^([-\w]+)\s*/); | ||
if (!m) return error("@keyframes missing name"); | ||
var name = m[1]; | ||
if (!open()) return error("@keyframes missing '{'"); | ||
var frame; | ||
var frames = comments(); | ||
while (frame = keyframe()) { | ||
frames.push(frame); | ||
frames = frames.concat(comments()); | ||
} | ||
if (!close()) return error("@keyframes missing '}'"); | ||
return pos({ | ||
type: 'keyframes', | ||
name: name, | ||
vendor: vendor, | ||
keyframes: frames | ||
}); | ||
} | ||
/** | ||
* Parse supports. | ||
*/ | ||
function atsupports() { | ||
var pos = position(); | ||
var m = match(/^@supports *([^{]+)/); | ||
if (!m) return; | ||
var supports = trim(m[1]); | ||
if (!open()) return error("@supports missing '{'"); | ||
var style = comments().concat(rules()); | ||
if (!close()) return error("@supports missing '}'"); | ||
return pos({ | ||
type: 'supports', | ||
supports: supports, | ||
rules: style | ||
}); | ||
} | ||
/** | ||
* Parse host. | ||
*/ | ||
function athost() { | ||
var pos = position(); | ||
var m = match(/^@host\s*/); | ||
if (!m) return; | ||
if (!open()) return error("@host missing '{'"); | ||
var style = comments().concat(rules()); | ||
if (!close()) return error("@host missing '}'"); | ||
return pos({ | ||
type: 'host', | ||
rules: style | ||
}); | ||
} | ||
/** | ||
* Parse media. | ||
*/ | ||
function atmedia() { | ||
var pos = position(); | ||
var m = match(/^@media *([^{]+)/); | ||
if (!m) return; | ||
var media = trim(m[1]); | ||
if (!open()) return error("@media missing '{'"); | ||
var style = comments().concat(rules()); | ||
if (!close()) return error("@media missing '}'"); | ||
return pos({ | ||
type: 'media', | ||
media: media, | ||
rules: style | ||
}); | ||
} | ||
/** | ||
* Parse custom-media. | ||
*/ | ||
function atcustommedia() { | ||
var pos = position(); | ||
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); | ||
if (!m) return; | ||
return pos({ | ||
type: 'custom-media', | ||
name: trim(m[1]), | ||
media: trim(m[2]) | ||
}); | ||
} | ||
/** | ||
* Parse paged media. | ||
*/ | ||
function atpage() { | ||
var pos = position(); | ||
var m = match(/^@page */); | ||
if (!m) return; | ||
var sel = selector() || []; | ||
if (!open()) return error("@page missing '{'"); | ||
var decls = comments(); | ||
// declarations | ||
var decl; | ||
while (decl = declaration()) { | ||
decls.push(decl); | ||
decls = decls.concat(comments()); | ||
} | ||
if (!close()) return error("@page missing '}'"); | ||
return pos({ | ||
type: 'page', | ||
selectors: sel, | ||
declarations: decls | ||
}); | ||
} | ||
/** | ||
* Parse document. | ||
*/ | ||
function atdocument() { | ||
var pos = position(); | ||
var m = match(/^@([-\w]+)?document *([^{]+)/); | ||
if (!m) return; | ||
var vendor = trim(m[1]); | ||
var doc = trim(m[2]); | ||
if (!open()) return error("@document missing '{'"); | ||
var style = comments().concat(rules()); | ||
if (!close()) return error("@document missing '}'"); | ||
return pos({ | ||
type: 'document', | ||
document: doc, | ||
vendor: vendor, | ||
rules: style | ||
}); | ||
} | ||
/** | ||
* Parse font-face. | ||
*/ | ||
function atfontface() { | ||
var pos = position(); | ||
var m = match(/^@font-face\s*/); | ||
if (!m) return; | ||
if (!open()) return error("@font-face missing '{'"); | ||
var decls = comments(); | ||
// declarations | ||
var decl; | ||
while (decl = declaration()) { | ||
decls.push(decl); | ||
decls = decls.concat(comments()); | ||
} | ||
if (!close()) return error("@font-face missing '}'"); | ||
return pos({ | ||
type: 'font-face', | ||
declarations: decls | ||
}); | ||
} | ||
/** | ||
* Parse import | ||
*/ | ||
var atimport = _compileAtrule('import'); | ||
/** | ||
* Parse charset | ||
*/ | ||
var atcharset = _compileAtrule('charset'); | ||
/** | ||
* Parse namespace | ||
*/ | ||
var atnamespace = _compileAtrule('namespace'); | ||
/** | ||
* Parse non-block at-rules | ||
*/ | ||
function _compileAtrule(name) { | ||
var re = new RegExp('^@' + name + '\\s*([^;]+);'); | ||
return function() { | ||
var pos = position(); | ||
var m = match(re); | ||
if (!m) return; | ||
var ret = { type: name }; | ||
ret[name] = m[1].trim(); | ||
return pos(ret); | ||
} | ||
} | ||
/** | ||
* Parse at rule. | ||
*/ | ||
function atrule() { | ||
if (css[0] != '@') return; | ||
return atkeyframes() | ||
|| atmedia() | ||
|| atcustommedia() | ||
|| atsupports() | ||
|| atimport() | ||
|| atcharset() | ||
|| atnamespace() | ||
|| atdocument() | ||
|| atpage() | ||
|| athost() | ||
|| atfontface(); | ||
} | ||
/** | ||
* Parse rule. | ||
*/ | ||
function rule() { | ||
var pos = position(); | ||
var sel = selector(); | ||
if (!sel) return error('selector missing'); | ||
comments(); | ||
return pos({ | ||
type: 'rule', | ||
selectors: sel, | ||
declarations: declarations() | ||
}); | ||
} | ||
return addParent(stylesheet()); | ||
}; | ||
/** | ||
* Trim `str`. | ||
*/ | ||
function trim(str) { | ||
return str ? str.replace(/^\s+|\s+$/g, '') : ''; | ||
} | ||
/** | ||
* Adds non-enumerable parent node reference to each node. | ||
*/ | ||
function addParent(obj, parent) { | ||
var isNode = obj && typeof obj.type === 'string'; | ||
var childParent = isNode ? obj : parent; | ||
for (var k in obj) { | ||
var value = obj[k]; | ||
if (Array.isArray(value)) { | ||
value.forEach(function(v) { addParent(v, childParent); }); | ||
} else if (value && typeof value === 'object') { | ||
addParent(value, childParent); | ||
} | ||
} | ||
if (isNode) { | ||
Object.defineProperty(obj, 'parent', { | ||
configurable: true, | ||
writable: true, | ||
enumerable: false, | ||
value: parent || null | ||
}); | ||
} | ||
return obj; | ||
} | ||
/***/ }), | ||
/* 14 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
@@ -1498,3 +2126,3 @@ | ||
*/ | ||
var domparser = __webpack_require__(13); | ||
var domparser = __webpack_require__(15); | ||
var utilities = __webpack_require__(1); | ||
@@ -1539,3 +2167,3 @@ var formatDOM = utilities.formatDOM; | ||
/***/ }), | ||
/* 13 */ | ||
/* 15 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1542,0 +2170,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.HTMLReactParser=t(require("react")):e.HTMLReactParser=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function n(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(e.indexOf("-")>0){for(var t=e.toLowerCase().split("-"),r=1,n=t.length;r<n;r++)t[r]=t[r].charAt(0).toUpperCase()+t[r].slice(1);return t.join("")}return e}function i(e,t){if("object"!=typeof e||!e)throw new TypeError("First argument must be an object");var r,n,i="function"==typeof t,o={},a={};for(r in e)n=e[r],i&&(o=t(r,n))&&2===o.length?a[o[0]]=o[1]:"string"==typeof n&&(a[n]=r);return a}e.exports={camelCase:n,invertObject:i}},function(e,t,r){"use strict";function n(e){for(var t,r={},n=0,i=e.length;n<i;n++)t=e[n],r[t.name]=t.value;return r}function i(e,t,r){t=t||null;for(var o,a,s,l=[],c=0,u=e.length;c<u;c++){switch(o=e[c],s={next:null,prev:l[c-1]||null,parent:t},a=l[c-1],a&&(a.next=s),0!==o.nodeName.indexOf("#")&&(s.name=o.nodeName.toLowerCase(),s.attribs={},o.attributes&&o.attributes.length&&(s.attribs=n(o.attributes))),o.nodeType){case 1:"script"===s.name||"style"===s.name?s.type=s.name:s.type="tag",s.children=i(o.childNodes,s);break;case 3:s.type="text",s.data=o.nodeValue;break;case 8:s.type="comment",s.data=o.nodeValue}l.push(s)}return r&&(l.unshift({name:r.substring(0,r.indexOf(" ")).toLowerCase(),data:r,type:"directive",next:l[0]?l[0]:null,prev:null,parent:t}),l[1]&&(l[1].prev=l[0])),l}function o(e){return e?document.documentMode===e:/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}e.exports={formatAttributes:n,formatDOM:i,isIE:o}},function(e,t,r){"use strict";function n(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");return i(o(e,a),t)}var i=r(3),o=r(12),a={decodeEntities:!0};e.exports=n},function(e,t,r){"use strict";function n(e,t){t=t||{};for(var r,a,s,l,c=[],u="function"==typeof t.replace,p=0,d=e.length;p<d;p++)if(r=e[p],u&&(a=t.replace(r),i.isValidElement(a)))d>1&&(a=i.cloneElement(a,{key:p})),c.push(a);else if("text"!==r.type){if(s=o(r.attribs),l=null,"script"===r.type||"style"===r.type)r.children[0]&&(s.dangerouslySetInnerHTML={__html:r.children[0].data});else{if("tag"!==r.type)continue;"textarea"===r.name&&r.children[0]?s.defaultValue=r.children[0].data:r.children&&r.children.length&&(l=n(r.children,t))}d>1&&(s.key=p),c.push(i.createElement(r.name,s,l))}else c.push(r.data);return 1===c.length?c[0]:c}var i=r(4),o=r(5);e.exports=n},function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e){e=e||{};var t,r,n,o={};for(t in e)r=e[t],l(t)?o[t]=r:(n=s.html[t.toLowerCase()],n?o[n]=r:(n=s.svg[t])&&(o[n]=r));return e.style&&(o.style=i(e.style)),o}function i(e){if("string"!=typeof e)throw new Error("`cssToJs`: first argument must be a string. ");for(var t,r,n,i={},a=e.split(";"),s=0,l=a.length;s<l;s++)if(t=a[s].trim().split(":"),2===t.length&&(t[0]=t[0].trim(),t[1]=t[1].trim(),t[0]&&t[1]))for(r=0,n=t.length;r<n;r++)i[o.camelCase(t[0])]=t[1];return i}var o=r(0),a=r(6),s=a.config,l=a.HTMLDOMPropertyConfig.isCustomAttribute;e.exports=n},function(e,t,r){"use strict";var n,i=r(0),o=r(7),a=r(11),s={html:{},svg:{}};s.html=i.invertObject(o.DOMAttributeNames);for(n in o.Properties)s.html[n.toLowerCase()]=n;s.svg=i.invertObject(a.DOMAttributeNames);for(n in a.Properties)s.html[n]=n;e.exports={config:s,HTMLDOMPropertyConfig:o,SVGDOMPropertyConfig:a}},function(e,t,r){"use strict";var n=r(8),i=n.injection.MUST_USE_PROPERTY,o=n.injection.HAS_BOOLEAN_VALUE,a=n.injection.HAS_NUMERIC_VALUE,s=n.injection.HAS_POSITIVE_NUMERIC_VALUE,l=n.injection.HAS_OVERLOADED_BOOLEAN_VALUE,c={isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+n.ATTRIBUTE_NAME_CHAR+"]*$")),Properties:{accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:o,allowTransparency:0,alt:0,as:0,async:o,autoComplete:0,autoPlay:o,capture:o,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:i|o,cite:0,classID:0,className:0,cols:s,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:o,controlsList:0,coords:0,crossOrigin:0,data:0,dateTime:0,default:o,defer:o,dir:0,disabled:o,download:l,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:o,formTarget:0,frameBorder:0,headers:0,height:0,hidden:o,high:0,href:0,hrefLang:0,htmlFor:0,httpEquiv:0,icon:0,id:0,inputMode:0,integrity:0,is:0,keyParams:0,keyType:0,kind:0,label:0,lang:0,list:0,loop:o,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:i|o,muted:i|o,name:0,nonce:0,noValidate:o,open:o,optimum:0,pattern:0,placeholder:0,playsInline:o,poster:0,preload:0,profile:0,radioGroup:0,readOnly:o,referrerPolicy:0,rel:0,required:o,reversed:o,role:0,rows:s,rowSpan:a,sandbox:0,scope:0,scoped:o,scrolling:0,seamless:o,selected:i|o,shape:0,size:s,sizes:0,span:s,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:a,step:0,style:0,summary:0,tabIndex:0,target:0,title:0,type:0,useMap:0,value:0,width:0,wmode:0,wrap:0,about:0,datatype:0,inlist:0,prefix:0,property:0,resource:0,typeof:0,vocab:0,autoCapitalize:0,autoCorrect:0,autoSave:0,color:0,itemProp:0,itemScope:o,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMPropertyNames:{},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}};e.exports=c},function(e,t,r){"use strict";function n(e,t){return(e&t)===t}var i=r(9),o=(r(10),{MUST_USE_PROPERTY:1,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,injectDOMPropertyConfig:function(e){var t=o,r=e.Properties||{},a=e.DOMAttributeNamespaces||{},l=e.DOMAttributeNames||{},c=e.DOMPropertyNames||{},u=e.DOMMutationMethods||{};e.isCustomAttribute&&s._isCustomAttributeFunctions.push(e.isCustomAttribute);for(var p in r){s.properties.hasOwnProperty(p)&&i("48",p);var d=p.toLowerCase(),m=r[p],f={attributeName:d,attributeNamespace:null,propertyName:p,mutationMethod:null,mustUseProperty:n(m,t.MUST_USE_PROPERTY),hasBooleanValue:n(m,t.HAS_BOOLEAN_VALUE),hasNumericValue:n(m,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:n(m,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:n(m,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(f.hasBooleanValue+f.hasNumericValue+f.hasOverloadedBooleanValue<=1||i("50",p),l.hasOwnProperty(p)){var h=l[p];f.attributeName=h}a.hasOwnProperty(p)&&(f.attributeNamespace=a[p]),c.hasOwnProperty(p)&&(f.propertyName=c[p]),u.hasOwnProperty(p)&&(f.mutationMethod=u[p]),s.properties[p]=f}}}),a=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",s={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:a,ATTRIBUTE_NAME_CHAR:a+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",properties:{},getPossibleStandardName:null,_isCustomAttributeFunctions:[],isCustomAttribute:function(e){for(var t=0;t<s._isCustomAttributeFunctions.length;t++){if((0,s._isCustomAttributeFunctions[t])(e))return!0}return!1},injection:o};e.exports=s},function(e,t,r){"use strict";function n(e){for(var t=arguments.length-1,r="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,n=0;n<t;n++)r+="&args[]="+encodeURIComponent(arguments[n+1]);r+=" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";var i=new Error(r);throw i.name="Invariant Violation",i.framesToPop=1,i}e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n,o,a,s,l){if(i(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,o,a,s,l],p=0;c=new Error(t.replace(/%s/g,function(){return u[p++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var i=function(e){};e.exports=n},function(e,t,r){"use strict";var n={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},i={accentHeight:"accent-height",accumulate:0,additive:0,alignmentBaseline:"alignment-baseline",allowReorder:"allowReorder",alphabetic:0,amplitude:0,arabicForm:"arabic-form",ascent:0,attributeName:"attributeName",attributeType:"attributeType",autoReverse:"autoReverse",azimuth:0,baseFrequency:"baseFrequency",baseProfile:"baseProfile",baselineShift:"baseline-shift",bbox:0,begin:0,bias:0,by:0,calcMode:"calcMode",capHeight:"cap-height",clip:0,clipPath:"clip-path",clipRule:"clip-rule",clipPathUnits:"clipPathUnits",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",contentScriptType:"contentScriptType",contentStyleType:"contentStyleType",cursor:0,cx:0,cy:0,d:0,decelerate:0,descent:0,diffuseConstant:"diffuseConstant",direction:0,display:0,divisor:0,dominantBaseline:"dominant-baseline",dur:0,dx:0,dy:0,edgeMode:"edgeMode",elevation:0,enableBackground:"enable-background",end:0,exponent:0,externalResourcesRequired:"externalResourcesRequired",fill:0,fillOpacity:"fill-opacity",fillRule:"fill-rule",filter:0,filterRes:"filterRes",filterUnits:"filterUnits",floodColor:"flood-color",floodOpacity:"flood-opacity",focusable:0,fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",glyphRef:"glyphRef",gradientTransform:"gradientTransform",gradientUnits:"gradientUnits",hanging:0,horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",ideographic:0,imageRendering:"image-rendering",in:0,in2:0,intercept:0,k:0,k1:0,k2:0,k3:0,k4:0,kernelMatrix:"kernelMatrix",kernelUnitLength:"kernelUnitLength",kerning:0,keyPoints:"keyPoints",keySplines:"keySplines",keyTimes:"keyTimes",lengthAdjust:"lengthAdjust",letterSpacing:"letter-spacing",lightingColor:"lighting-color",limitingConeAngle:"limitingConeAngle",local:0,markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",markerHeight:"markerHeight",markerUnits:"markerUnits",markerWidth:"markerWidth",mask:0,maskContentUnits:"maskContentUnits",maskUnits:"maskUnits",mathematical:0,mode:0,numOctaves:"numOctaves",offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pathLength:"pathLength",patternContentUnits:"patternContentUnits",patternTransform:"patternTransform",patternUnits:"patternUnits",pointerEvents:"pointer-events",points:0,pointsAtX:"pointsAtX",pointsAtY:"pointsAtY",pointsAtZ:"pointsAtZ",preserveAlpha:"preserveAlpha",preserveAspectRatio:"preserveAspectRatio",primitiveUnits:"primitiveUnits",r:0,radius:0,refX:"refX",refY:"refY",renderingIntent:"rendering-intent",repeatCount:"repeatCount",repeatDur:"repeatDur",requiredExtensions:"requiredExtensions",requiredFeatures:"requiredFeatures",restart:0,result:0,rotate:0,rx:0,ry:0,scale:0,seed:0,shapeRendering:"shape-rendering",slope:0,spacing:0,specularConstant:"specularConstant",specularExponent:"specularExponent",speed:0,spreadMethod:"spreadMethod",startOffset:"startOffset",stdDeviation:"stdDeviation",stemh:0,stemv:0,stitchTiles:"stitchTiles",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",string:0,stroke:0,strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",surfaceScale:"surfaceScale",systemLanguage:"systemLanguage",tableValues:"tableValues",targetX:"targetX",targetY:"targetY",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",textLength:"textLength",to:0,transform:0,u1:0,u2:0,underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicode:0,unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",values:0,vectorEffect:"vector-effect",version:0,vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",viewBox:"viewBox",viewTarget:"viewTarget",visibility:0,widths:0,wordSpacing:"word-spacing",writingMode:"writing-mode",x:0,xHeight:"x-height",x1:0,x2:0,xChannelSelector:"xChannelSelector",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlns:0,xmlnsXlink:"xmlns:xlink",xmlLang:"xml:lang",xmlSpace:"xml:space",y:0,y1:0,y2:0,yChannelSelector:"yChannelSelector",z:0,zoomAndPan:"zoomAndPan"},o={Properties:{},DOMAttributeNamespaces:{xlinkActuate:n.xlink,xlinkArcrole:n.xlink,xlinkHref:n.xlink,xlinkRole:n.xlink,xlinkShow:n.xlink,xlinkTitle:n.xlink,xlinkType:n.xlink,xmlBase:n.xml,xmlLang:n.xml,xmlSpace:n.xml},DOMAttributeNames:{}};Object.keys(i).forEach(function(e){o.Properties[e]=0,i[e]&&(o.DOMAttributeNames[e]=i[e])}),e.exports=o},function(e,t,r){"use strict";var n=r(13),i=r(1),o=i.formatDOM,a=i.isIE(9),s=/<(![a-zA-Z\s]+)>/;e.exports=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");if(!e)return[];var t,r=e.match(s);return r&&r[1]&&(t=r[1],a&&(e=e.replace(r[0],""))),o(n(e),null,t)}},function(e,t,r){"use strict";var n,i=r(1),o=i.isIE,a=/<([a-zA-Z]+[0-9]?)/,s=/<head[\s\S]*>[\s\S]*<\/head>/i,l=/<body[\s\S]*>[\s\S]*<\/body>/i,c=/<(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)(.*?)\/?>/gi,u=o(),p=o(9);if("function"==typeof window.DOMParser){var d=new window.DOMParser,m=p?"text/xml":"text/html";n=function(e,t){return t&&(e=["<",t,">",e,"</",t,">"].join("")),p&&(e=e.replace(c,"<$1$2$3/>")),d.parseFromString(e,m)}}var f;if("object"==typeof document.implementation){var h=document.implementation.createHTMLDocument(u?"HTML_DOM_PARSER_TITLE":void 0);f=function(e,t){if(t)return h.documentElement.getElementsByTagName(t)[0].innerHTML=e,h;try{return h.documentElement.innerHTML=e,h}catch(t){if(n)return n(e)}}}var g,y=document.createElement("template");y.content&&(g=function(e){return y.innerHTML=e,y.content.childNodes});var v=f||n;e.exports=function(e){var t,r=e.match(a);r&&r[1]&&(t=r[1]);var i,o,c;switch(t){case"html":if(n)return i=n(e),s.test(e)||(o=i.getElementsByTagName("head")[0])&&o.parentNode.removeChild(o),l.test(e)||(o=i.getElementsByTagName("body")[0])&&o.parentNode.removeChild(o),i.getElementsByTagName("html");break;case"head":if(v)return c=v(e).getElementsByTagName("head"),l.test(e)?c[0].parentNode.childNodes:c;break;case"body":if(v)return c=v(e).getElementsByTagName("body"),s.test(e)?c[0].parentNode.childNodes:c;break;default:if(g)return g(e);if(v)return v(e,"body").getElementsByTagName("body")[0].childNodes}return[]}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.HTMLReactParser=t(require("react")):e.HTMLReactParser=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function n(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");return e.indexOf("-")<0?e:e.toLowerCase().replace(a,function(e,t){return t.toUpperCase()})}function i(e,t){if("object"!=typeof e||!e)throw new TypeError("First argument must be an object");var r,n,i="function"==typeof t,a={},o={};for(r in e)n=e[r],i&&(a=t(r,n))&&2===a.length?o[a[0]]=a[1]:"string"==typeof n&&(o[n]=r);return o}var a=/-(.)/g;e.exports={camelCase:n,invertObject:i}},function(e,t,r){"use strict";function n(e){for(var t,r={},n=0,i=e.length;n<i;n++)t=e[n],r[t.name]=t.value;return r}function i(e,t,r){t=t||null;for(var a,o,s,l=[],u=0,c=e.length;u<c;u++){switch(a=e[u],s={next:null,prev:l[u-1]||null,parent:t},o=l[u-1],o&&(o.next=s),0!==a.nodeName.indexOf("#")&&(s.name=a.nodeName.toLowerCase(),s.attribs={},a.attributes&&a.attributes.length&&(s.attribs=n(a.attributes))),a.nodeType){case 1:"script"===s.name||"style"===s.name?s.type=s.name:s.type="tag",s.children=i(a.childNodes,s);break;case 3:s.type="text",s.data=a.nodeValue;break;case 8:s.type="comment",s.data=a.nodeValue}l.push(s)}return r&&(l.unshift({name:r.substring(0,r.indexOf(" ")).toLowerCase(),data:r,type:"directive",next:l[0]?l[0]:null,prev:null,parent:t}),l[1]&&(l[1].prev=l[0])),l}function a(e){return e?document.documentMode===e:/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}e.exports={formatAttributes:n,formatDOM:i,isIE:a}},function(e,t,r){"use strict";function n(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");return i(a(e,o),t)}var i=r(3),a=r(14),o={decodeEntities:!0};e.exports=n},function(e,t,r){"use strict";function n(e,t){t=t||{};for(var r,o,s,l,u=[],c="function"==typeof t.replace,p=0,f=e.length;p<f;p++)if(r=e[p],c&&(o=t.replace(r),i.isValidElement(o)))f>1&&(o=i.cloneElement(o,{key:p})),u.push(o);else if("text"!==r.type){if(s=a(r.attribs),l=null,"script"===r.type||"style"===r.type)r.children[0]&&(s.dangerouslySetInnerHTML={__html:r.children[0].data});else{if("tag"!==r.type)continue;"textarea"===r.name&&r.children[0]?s.defaultValue=r.children[0].data:r.children&&r.children.length&&(l=n(r.children,t))}f>1&&(s.key=p),u.push(i.createElement(r.name,s,l))}else u.push(r.data);return 1===u.length?u[0]:u}var i=r(4),a=r(5);e.exports=n},function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e){e=e||{};var t,r,n,a={};for(t in e)r=e[t],u(t)?a[t]=r:(n=l.html[t.toLowerCase()],n?a[n]=r:(n=l.svg[t])&&(a[n]=r));return e.style&&(a.style=i(e.style)),a}function i(e){if("string"!=typeof e)throw new Error("`cssToJs`: first argument must be a string. ");var t={};return s(e,function(e,r){e&&r&&(t[a.camelCase(e)]=r)}),t}var a=r(0),o=r(6),s=r(12),l=o.config,u=o.HTMLDOMPropertyConfig.isCustomAttribute;e.exports=n},function(e,t,r){"use strict";var n,i=r(0),a=r(7),o=r(11),s={html:{},svg:{}};s.html=i.invertObject(a.DOMAttributeNames);for(n in a.Properties)s.html[n.toLowerCase()]=n;s.svg=i.invertObject(o.DOMAttributeNames);for(n in o.Properties)s.html[n]=n;e.exports={config:s,HTMLDOMPropertyConfig:a,SVGDOMPropertyConfig:o}},function(e,t,r){"use strict";var n=r(8),i=n.injection.MUST_USE_PROPERTY,a=n.injection.HAS_BOOLEAN_VALUE,o=n.injection.HAS_NUMERIC_VALUE,s=n.injection.HAS_POSITIVE_NUMERIC_VALUE,l=n.injection.HAS_OVERLOADED_BOOLEAN_VALUE,u={isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+n.ATTRIBUTE_NAME_CHAR+"]*$")),Properties:{accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:a,allowTransparency:0,alt:0,as:0,async:a,autoComplete:0,autoPlay:a,capture:a,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:i|a,cite:0,classID:0,className:0,cols:s,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:a,controlsList:0,coords:0,crossOrigin:0,data:0,dateTime:0,default:a,defer:a,dir:0,disabled:a,download:l,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:a,formTarget:0,frameBorder:0,headers:0,height:0,hidden:a,high:0,href:0,hrefLang:0,htmlFor:0,httpEquiv:0,icon:0,id:0,inputMode:0,integrity:0,is:0,keyParams:0,keyType:0,kind:0,label:0,lang:0,list:0,loop:a,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:i|a,muted:i|a,name:0,nonce:0,noValidate:a,open:a,optimum:0,pattern:0,placeholder:0,playsInline:a,poster:0,preload:0,profile:0,radioGroup:0,readOnly:a,referrerPolicy:0,rel:0,required:a,reversed:a,role:0,rows:s,rowSpan:o,sandbox:0,scope:0,scoped:a,scrolling:0,seamless:a,selected:i|a,shape:0,size:s,sizes:0,span:s,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:o,step:0,style:0,summary:0,tabIndex:0,target:0,title:0,type:0,useMap:0,value:0,width:0,wmode:0,wrap:0,about:0,datatype:0,inlist:0,prefix:0,property:0,resource:0,typeof:0,vocab:0,autoCapitalize:0,autoCorrect:0,autoSave:0,color:0,itemProp:0,itemScope:a,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMPropertyNames:{},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}};e.exports=u},function(e,t,r){"use strict";function n(e,t){return(e&t)===t}var i=r(9),a=(r(10),{MUST_USE_PROPERTY:1,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,injectDOMPropertyConfig:function(e){var t=a,r=e.Properties||{},o=e.DOMAttributeNamespaces||{},l=e.DOMAttributeNames||{},u=e.DOMPropertyNames||{},c=e.DOMMutationMethods||{};e.isCustomAttribute&&s._isCustomAttributeFunctions.push(e.isCustomAttribute);for(var p in r){s.properties.hasOwnProperty(p)&&i("48",p);var f=p.toLowerCase(),m=r[p],d={attributeName:f,attributeNamespace:null,propertyName:p,mutationMethod:null,mustUseProperty:n(m,t.MUST_USE_PROPERTY),hasBooleanValue:n(m,t.HAS_BOOLEAN_VALUE),hasNumericValue:n(m,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:n(m,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:n(m,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(d.hasBooleanValue+d.hasNumericValue+d.hasOverloadedBooleanValue<=1||i("50",p),l.hasOwnProperty(p)){var h=l[p];d.attributeName=h}o.hasOwnProperty(p)&&(d.attributeNamespace=o[p]),u.hasOwnProperty(p)&&(d.propertyName=u[p]),c.hasOwnProperty(p)&&(d.mutationMethod=c[p]),s.properties[p]=d}}}),o=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",s={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:o,ATTRIBUTE_NAME_CHAR:o+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",properties:{},getPossibleStandardName:null,_isCustomAttributeFunctions:[],isCustomAttribute:function(e){for(var t=0;t<s._isCustomAttributeFunctions.length;t++){if((0,s._isCustomAttributeFunctions[t])(e))return!0}return!1},injection:a};e.exports=s},function(e,t,r){"use strict";function n(e){for(var t=arguments.length-1,r="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,n=0;n<t;n++)r+="&args[]="+encodeURIComponent(arguments[n+1]);r+=" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";var i=new Error(r);throw i.name="Invariant Violation",i.framesToPop=1,i}e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n,a,o,s,l){if(i(t),!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,a,o,s,l],p=0;u=new Error(t.replace(/%s/g,function(){return c[p++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}}var i=function(e){};e.exports=n},function(e,t,r){"use strict";var n={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},i={accentHeight:"accent-height",accumulate:0,additive:0,alignmentBaseline:"alignment-baseline",allowReorder:"allowReorder",alphabetic:0,amplitude:0,arabicForm:"arabic-form",ascent:0,attributeName:"attributeName",attributeType:"attributeType",autoReverse:"autoReverse",azimuth:0,baseFrequency:"baseFrequency",baseProfile:"baseProfile",baselineShift:"baseline-shift",bbox:0,begin:0,bias:0,by:0,calcMode:"calcMode",capHeight:"cap-height",clip:0,clipPath:"clip-path",clipRule:"clip-rule",clipPathUnits:"clipPathUnits",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",contentScriptType:"contentScriptType",contentStyleType:"contentStyleType",cursor:0,cx:0,cy:0,d:0,decelerate:0,descent:0,diffuseConstant:"diffuseConstant",direction:0,display:0,divisor:0,dominantBaseline:"dominant-baseline",dur:0,dx:0,dy:0,edgeMode:"edgeMode",elevation:0,enableBackground:"enable-background",end:0,exponent:0,externalResourcesRequired:"externalResourcesRequired",fill:0,fillOpacity:"fill-opacity",fillRule:"fill-rule",filter:0,filterRes:"filterRes",filterUnits:"filterUnits",floodColor:"flood-color",floodOpacity:"flood-opacity",focusable:0,fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",glyphRef:"glyphRef",gradientTransform:"gradientTransform",gradientUnits:"gradientUnits",hanging:0,horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",ideographic:0,imageRendering:"image-rendering",in:0,in2:0,intercept:0,k:0,k1:0,k2:0,k3:0,k4:0,kernelMatrix:"kernelMatrix",kernelUnitLength:"kernelUnitLength",kerning:0,keyPoints:"keyPoints",keySplines:"keySplines",keyTimes:"keyTimes",lengthAdjust:"lengthAdjust",letterSpacing:"letter-spacing",lightingColor:"lighting-color",limitingConeAngle:"limitingConeAngle",local:0,markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",markerHeight:"markerHeight",markerUnits:"markerUnits",markerWidth:"markerWidth",mask:0,maskContentUnits:"maskContentUnits",maskUnits:"maskUnits",mathematical:0,mode:0,numOctaves:"numOctaves",offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pathLength:"pathLength",patternContentUnits:"patternContentUnits",patternTransform:"patternTransform",patternUnits:"patternUnits",pointerEvents:"pointer-events",points:0,pointsAtX:"pointsAtX",pointsAtY:"pointsAtY",pointsAtZ:"pointsAtZ",preserveAlpha:"preserveAlpha",preserveAspectRatio:"preserveAspectRatio",primitiveUnits:"primitiveUnits",r:0,radius:0,refX:"refX",refY:"refY",renderingIntent:"rendering-intent",repeatCount:"repeatCount",repeatDur:"repeatDur",requiredExtensions:"requiredExtensions",requiredFeatures:"requiredFeatures",restart:0,result:0,rotate:0,rx:0,ry:0,scale:0,seed:0,shapeRendering:"shape-rendering",slope:0,spacing:0,specularConstant:"specularConstant",specularExponent:"specularExponent",speed:0,spreadMethod:"spreadMethod",startOffset:"startOffset",stdDeviation:"stdDeviation",stemh:0,stemv:0,stitchTiles:"stitchTiles",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",string:0,stroke:0,strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",surfaceScale:"surfaceScale",systemLanguage:"systemLanguage",tableValues:"tableValues",targetX:"targetX",targetY:"targetY",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",textLength:"textLength",to:0,transform:0,u1:0,u2:0,underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicode:0,unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",values:0,vectorEffect:"vector-effect",version:0,vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",viewBox:"viewBox",viewTarget:"viewTarget",visibility:0,widths:0,wordSpacing:"word-spacing",writingMode:"writing-mode",x:0,xHeight:"x-height",x1:0,x2:0,xChannelSelector:"xChannelSelector",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlns:0,xmlnsXlink:"xmlns:xlink",xmlLang:"xml:lang",xmlSpace:"xml:space",y:0,y1:0,y2:0,yChannelSelector:"yChannelSelector",z:0,zoomAndPan:"zoomAndPan"},a={Properties:{},DOMAttributeNamespaces:{xlinkActuate:n.xlink,xlinkArcrole:n.xlink,xlinkHref:n.xlink,xlinkRole:n.xlink,xlinkShow:n.xlink,xlinkTitle:n.xlink,xlinkType:n.xlink,xmlBase:n.xml,xmlLang:n.xml,xmlSpace:n.xml},DOMAttributeNames:{}};Object.keys(i).forEach(function(e){a.Properties[e]=0,i[e]&&(a.DOMAttributeNames[e]=i[e])}),e.exports=a},function(e,t,r){var n=r(13);e.exports=function(e,t){if(!e||"string"!=typeof e)return null;for(var r,i,a,o=n("p{"+e+"}").stylesheet.rules[0].declarations,s=null,l="function"==typeof t,u=0,c=o.length;u<c;u++)r=o[u],i=r.property,a=r.value,l?t(i,a,r):a&&(s||(s={}),s[i]=a);return s}},function(e,t){function r(e){return e?e.replace(/^\s+|\s+$/g,""):""}function n(e,t){var r=e&&"string"==typeof e.type,i=r?e:t;for(var a in e){var o=e[a];Array.isArray(o)?o.forEach(function(e){n(e,i)}):o&&"object"==typeof o&&n(o,i)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var i=/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//g;e.exports=function(e,t){function a(e){var t=e.match(/\n/g);t&&(_+=t.length);var r=e.lastIndexOf("\n");R=~r?e.length-r:R+e.length}function o(){var e={line:_,column:R};return function(t){return t.position=new s(e),m(),t}}function s(e){this.start=e,this.end={line:_,column:R},this.source=t.source}function l(r){var n=new Error(t.source+":"+_+":"+R+": "+r);if(n.reason=r,n.filename=t.source,n.line=_,n.column=R,n.source=e,!t.silent)throw n;P.push(n)}function u(){return f(/^{\s*/)}function c(){return f(/^}/)}function p(){var t,r=[];for(m(),d(r);e.length&&"}"!=e.charAt(0)&&(t=S()||N());)!1!==t&&(r.push(t),d(r));return r}function f(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function m(){f(/^\s*/)}function d(e){var t;for(e=e||[];t=h();)!1!==t&&e.push(t);return e}function h(){var t=o();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return l("End of comment missing");var n=e.slice(2,r-2);return R+=2,a(n),e=e.slice(r),R+=2,t({type:"comment",comment:n})}}function g(){var e=f(/^([^{]+)/);if(e)return r(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function y(){var e=o(),t=f(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){if(t=r(t[0]),!f(/^:\s*/))return l("property missing ':'");var n=f(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:t.replace(i,""),value:n?r(n[0]).replace(i,""):""});return f(/^[;\s]*/),a}}function v(){var e=[];if(!u())return l("missing '{'");d(e);for(var t;t=y();)!1!==t&&(e.push(t),d(e));return c()?e:l("missing '}'")}function x(){for(var e,t=[],r=o();e=f(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),f(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:v()})}function b(){var e=o(),t=f(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1],t=f(/^([-\w]+)\s*/);if(!t)return l("@keyframes missing name");var n=t[1];if(!u())return l("@keyframes missing '{'");for(var i,a=d();i=x();)a.push(i),a=a.concat(d());return c()?e({type:"keyframes",name:n,vendor:r,keyframes:a}):l("@keyframes missing '}'")}}function k(){var e=o(),t=f(/^@supports *([^{]+)/);if(t){var n=r(t[1]);if(!u())return l("@supports missing '{'");var i=d().concat(p());return c()?e({type:"supports",supports:n,rules:i}):l("@supports missing '}'")}}function A(){var e=o();if(f(/^@host\s*/)){if(!u())return l("@host missing '{'");var t=d().concat(p());return c()?e({type:"host",rules:t}):l("@host missing '}'")}}function E(){var e=o(),t=f(/^@media *([^{]+)/);if(t){var n=r(t[1]);if(!u())return l("@media missing '{'");var i=d().concat(p());return c()?e({type:"media",media:n,rules:i}):l("@media missing '}'")}}function T(){var e=o(),t=f(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:r(t[1]),media:r(t[2])})}function w(){var e=o();if(f(/^@page */)){var t=g()||[];if(!u())return l("@page missing '{'");for(var r,n=d();r=y();)n.push(r),n=n.concat(d());return c()?e({type:"page",selectors:t,declarations:n}):l("@page missing '}'")}}function O(){var e=o(),t=f(/^@([-\w]+)?document *([^{]+)/);if(t){var n=r(t[1]),i=r(t[2]);if(!u())return l("@document missing '{'");var a=d().concat(p());return c()?e({type:"document",document:i,vendor:n,rules:a}):l("@document missing '}'")}}function M(){var e=o();if(f(/^@font-face\s*/)){if(!u())return l("@font-face missing '{'");for(var t,r=d();t=y();)r.push(t),r=r.concat(d());return c()?e({type:"font-face",declarations:r}):l("@font-face missing '}'")}}function C(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=o(),n=f(t);if(n){var i={type:e};return i[e]=n[1].trim(),r(i)}}}function S(){if("@"==e[0])return b()||E()||T()||k()||L()||U()||D()||O()||w()||A()||M()}function N(){var e=o(),t=g();return t?(d(),e({type:"rule",selectors:t,declarations:v()})):l("selector missing")}t=t||{};var _=1,R=1;s.prototype.content=e;var P=[],L=C("import"),U=C("charset"),D=C("namespace");return n(function(){return{type:"stylesheet",stylesheet:{rules:p(),parsingErrors:P}}}())}},function(e,t,r){"use strict";var n=r(15),i=r(1),a=i.formatDOM,o=i.isIE(9),s=/<(![a-zA-Z\s]+)>/;e.exports=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");if(!e)return[];var t,r=e.match(s);return r&&r[1]&&(t=r[1],o&&(e=e.replace(r[0],""))),a(n(e),null,t)}},function(e,t,r){"use strict";var n,i=r(1),a=i.isIE,o=/<([a-zA-Z]+[0-9]?)/,s=/<head[\s\S]*>[\s\S]*<\/head>/i,l=/<body[\s\S]*>[\s\S]*<\/body>/i,u=/<(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)(.*?)\/?>/gi,c=a(),p=a(9);if("function"==typeof window.DOMParser){var f=new window.DOMParser,m=p?"text/xml":"text/html";n=function(e,t){return t&&(e=["<",t,">",e,"</",t,">"].join("")),p&&(e=e.replace(u,"<$1$2$3/>")),f.parseFromString(e,m)}}var d;if("object"==typeof document.implementation){var h=document.implementation.createHTMLDocument(c?"HTML_DOM_PARSER_TITLE":void 0);d=function(e,t){if(t)return h.documentElement.getElementsByTagName(t)[0].innerHTML=e,h;try{return h.documentElement.innerHTML=e,h}catch(t){if(n)return n(e)}}}var g,y=document.createElement("template");y.content&&(g=function(e){return y.innerHTML=e,y.content.childNodes});var v=d||n;e.exports=function(e){var t,r=e.match(o);r&&r[1]&&(t=r[1]);var i,a,u;switch(t){case"html":if(n)return i=n(e),s.test(e)||(a=i.getElementsByTagName("head")[0])&&a.parentNode.removeChild(a),l.test(e)||(a=i.getElementsByTagName("body")[0])&&a.parentNode.removeChild(a),i.getElementsByTagName("html");break;case"head":if(v)return u=v(e).getElementsByTagName("head"),l.test(e)?u[0].parentNode.childNodes:u;break;case"body":if(v)return u=v(e).getElementsByTagName("body"),s.test(e)?u[0].parentNode.childNodes:u;break;default:if(g)return g(e);if(v)return v(e,"body").getElementsByTagName("body")[0].childNodes}return[]}}])}); |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var propertyConfig = require('./property-config'); | ||
var styleToObject = require('style-to-object'); | ||
var config = propertyConfig.config; | ||
@@ -67,29 +68,12 @@ var isCustomAttribute = propertyConfig.HTMLDOMPropertyConfig.isCustomAttribute; | ||
var result = {}; | ||
// e.g., `color: #f00` | ||
var declarations = style.split(';'); | ||
// css property itemized as key and value | ||
var properties; | ||
var j; | ||
var propertiesLen; | ||
var styleObj = {}; | ||
for (var i = 0, declarationsLen = declarations.length; i < declarationsLen; i++) { | ||
properties = declarations[i].trim().split(':'); | ||
// skip if not a css property | ||
if (properties.length !== 2) { continue; } | ||
// css property name | ||
properties[0] = properties[0].trim(); | ||
// css property value | ||
properties[1] = properties[1].trim(); | ||
if (properties[0] && properties[1]) { | ||
for (j = 0, propertiesLen = properties.length; j < propertiesLen; j++) { | ||
result[utilities.camelCase(properties[0])] = properties[1]; | ||
} | ||
styleToObject(style, function(propName, propValue) { | ||
// Check if it's not a comment node | ||
if (propName && propValue) { | ||
styleObj[utilities.camelCase(propName)] = propValue; | ||
} | ||
} | ||
}); | ||
return result; | ||
return styleObj; | ||
} | ||
@@ -96,0 +80,0 @@ |
'use strict'; | ||
var _hyphenPattern = /-(.)/g; | ||
/** | ||
@@ -10,19 +12,11 @@ * Convert a string to camel case. | ||
function camelCase(string) { | ||
if (typeof string !== 'string') { | ||
if (typeof string !== 'string') { // null is an object | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
// hyphen found after first character | ||
if (string.indexOf('-') > 0) { | ||
var strings = string.toLowerCase().split('-'); | ||
// capitalize starting from the second string item | ||
for (var i = 1, len = strings.length; i < len; i++) { | ||
strings[i] = strings[i].charAt(0).toUpperCase() + strings[i].slice(1); | ||
} | ||
return strings.join(''); | ||
if(string.indexOf('-') < 0) { | ||
return string; | ||
} | ||
return string; | ||
return string.toLowerCase().replace(_hyphenPattern, function(_, character) { | ||
return character.toUpperCase(); | ||
}); | ||
} | ||
@@ -29,0 +23,0 @@ |
{ | ||
"name": "html-react-parser", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "An HTML to React parser.", | ||
@@ -33,3 +33,4 @@ "author": "Mark <mark@remarkablemark.org>", | ||
"html-dom-parser": "0.1.2", | ||
"react-dom-core": "0.0.2" | ||
"react-dom-core": "0.0.2", | ||
"style-to-object": "0.2.0" | ||
}, | ||
@@ -36,0 +37,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103512
2298
4
+ Addedstyle-to-object@0.2.0
+ Addedamdefine@1.0.1(transitive)
+ Addedatob@1.1.3(transitive)
+ Addedcss@2.2.1(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedsource-map@0.1.43(transitive)
+ Addedsource-map-resolve@0.3.1(transitive)
+ Addedsource-map-url@0.3.0(transitive)
+ Addedstyle-to-object@0.2.0(transitive)
+ Addedurix@0.1.0(transitive)