vuepress-playground
Version:
15 lines (14 loc) • 384 B
JavaScript
export default function createElement (tag, attrs) {
const node = document.createElement(tag)
attrs && Object.keys(attrs).forEach(key => {
node[key] = attrs[key]
})
attrs && attrs.__children && attrs.__children.forEach(({
tag: subTag,
attrs: subAttrs
}) => {
const subNode = createElement(subTag, subAttrs)
node.appendChild(subNode)
})
return node
}