Skip to content

Commit

Permalink
Fixed issue for img tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitk05 committed Aug 25, 2019
1 parent 1e0ff36 commit a7dbc78
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/index.js
Expand Up @@ -17,6 +17,10 @@ function getProps(el) {
if(k === 'className') {
props[k] = el[k]
}

if (k === "src") {
props[k] = el[k];
}
}
props = Object.assign(props, events)
return props
Expand All @@ -30,6 +34,13 @@ function getChildren(elements) {
let props = { ...getProps(el) }
if (el.childElementCount) {
children.push(React.createElement(el.tagName.toLowerCase(), props === {} ? null : props, ...getChildren(el.children)))
} else if (el.tagName.toLowerCase() === 'img') {
children.push(
React.createElement(
el.tagName.toLowerCase(),
props === {} ? null : props
)
);
} else if (el.textContent) {
children.push(React.createElement(el.tagName.toLowerCase(), props === {} ? null : props, el.textContent))
}
Expand Down

0 comments on commit a7dbc78

Please sign in to comment.