Skip to content

Instantly share code, notes, and snippets.

@CaitlinWeb-st
CaitlinWeb-st / SlotWrapper.js
Created Nov 4, 2020
Vue component for slots to ensure each element has class(es) or tag
View SlotWrapper.js
/**
* Ensures each child node (element or text) of the slot has a given tag or class.
*/
export default {
name: "SlotWrapper",
functional: true,
props: ["tag", "value"],
render: function(h, ctx) {
const { tag = "div", value: node, class: className = "" } = ctx.props;