Skip to content

Instantly share code, notes, and snippets.

@calebporzio
Created August 24, 2018 01:30
Show Gist options
  • Save calebporzio/c9c0d5dc07ae72997342c5cd1e9065a7 to your computer and use it in GitHub Desktop.
Save calebporzio/c9c0d5dc07ae72997342c5cd1e9065a7 to your computer and use it in GitHub Desktop.
<script>
export default {
props: ['icon'],
render(h) {
let svgHtml = require(`!html-loader!./../../svg/${this.icon}.svg`)
let wrapper = document.createElement('div')
wrapper.innerHTML = svgHtml
let node = wrapper.firstChild
let attrs = {}
node.getAttributeNames().forEach(name => {
attrs[name] = node.getAttribute(name)
})
delete attrs.height
delete attrs.width
return h('svg', {
class: [ 'svg-icon' ],
attrs: attrs,
domProps: {
innerHTML: node.innerHTML
}
})
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment