Skip to content

Instantly share code, notes, and snippets.

@mach3 mach3/mixin.js
Created Aug 6, 2019

Embed
What would you like to do?
vnodeRender
export const vnodeRender = {
methods: {
vnodeRender(vnode) {
if (process.browser) {
if (!vnode.tag) {
return document.createTextNode(vnode.text)
}
const el = document.createElement(vnode.tag)
if (vnode.data) {
if (vnode.data.staticClass) {
el.setAttribute('class', vnode.data.staticClass)
}
if (vnode.data.attrs) {
Object.keys(vnode.data.attrs)
.forEach((key) => {
el.setAttribute(key, vnode.data.attrs[key])
})
}
}
if (vnode.children) {
vnode.children.forEach((child) => {
el.appendChild(this.vnodeRender(child))
})
}
return el
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.