I'm trying to create a functional component that renders the Feather Icons package but I'm not able to figure out the last step. Here's what I got:
This is my FeatherIcon.vue component.
<script>
const feather = require("feather-icons");
export default {
components: {},
props: {
type: {
required: true,
type: String
}
},
mounted() {},
render(createElement) {
return createElement(
"svg",
{attrs: feather.icons[this.type].attrs },
feather.icons[this.type].contents
);
}
};
</script>
The 3rd argument according to Vue docs says that it should be either:
// {String | Array}
// Children VNodes, built using `createElement()`,
// or using strings to get 'text VNodes'. Optional.
However, the result of my 3rd argument feather.icon[this.type].contents is a string containing the "innerHTML" inside the svg tag:
"<line x1="6" y1="3" x2="6" y2="15"></line><circle cx="18" cy="6" r="3"></circle><circle cx="6" cy="18" r="3"></circle><path d="M18 9a9 9 0 0 1-9 9"></path>"
So my question is, how to convert feather.icon[this.type].contents into a set of VNodes?
I've tried with DOMParser and using parseFromString but no luck. Any idea?