html-element-to-react
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -35,10 +35,10 @@ "use strict"; | ||
if (/^on/.test(k) && el[k]) { | ||
events[camelCase(k, 'on')] = el[k]; | ||
events[camelCase(k, "on")] = el[k]; | ||
} | ||
if (k === 'className') { | ||
if (k === "className" && el[k]) { | ||
props[k] = el[k]; | ||
} | ||
if (k === "src") { | ||
if (k === "src" && el[k]) { | ||
props[k] = el[k]; | ||
@@ -61,8 +61,12 @@ } | ||
if (el.childElementCount) { | ||
children.push(_react["default"].createElement.apply(_react["default"], [el.tagName.toLowerCase(), props === {} ? null : props].concat(_toConsumableArray(getChildren(el.children))))); | ||
} else if (el.tagName.toLowerCase() === 'img') { | ||
children.push(_react["default"].createElement(el.tagName.toLowerCase(), props === {} ? null : props)); | ||
} else if (el.textContent) { | ||
children.push(_react["default"].createElement(el.tagName.toLowerCase(), props === {} ? null : props, el.textContent)); | ||
if (el.childNodes.length) { | ||
children.push(_react["default"].createElement.apply(_react["default"], [el.tagName.toLowerCase(), props === {} ? null : props].concat(_toConsumableArray(getChildren(el.childNodes))))); | ||
} else { | ||
if (el.nodeType === 3) { | ||
children.push(el.textContent); | ||
} else if (el.nodeType === 1) { | ||
if (["VIDEO", "IMG", "AUDIO"].includes(el.nodeName)) { | ||
children.push(_react["default"].createElement(el.tagName.toLowerCase(), props === {} ? null : props)); | ||
} | ||
} | ||
} | ||
@@ -79,5 +83,5 @@ } | ||
return _react["default"].createElement.apply(_react["default"], [domElement.tagName.toLowerCase(), props === {} ? null : props].concat(_toConsumableArray(getChildren(domElement.children)))); | ||
return _react["default"].createElement.apply(_react["default"], [domElement.tagName.toLowerCase(), props === {} ? null : props].concat(_toConsumableArray(getChildren(domElement.childNodes)))); | ||
}; | ||
exports.convert = convert; |
{ | ||
"name": "html-element-to-react", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Convert HTML DOM elements to React elements", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
5387
60