1
// Types
2 1
import Vue, { VNode } from 'vue'
3

4 1
export default function VGrid (name: string) {
5
  /* @vue/component */
6 1
  return Vue.extend({
7
    name: `v-${name}`,
8

9
    functional: true,
10

11
    props: {
12
      id: String,
13
      tag: {
14
        type: String,
15
        default: 'div',
16
      },
17
    },
18

19 1
    render (h, { props, data, children }): VNode {
20 1
      data.staticClass = (`${name} ${data.staticClass || ''}`).trim()
21

22 1
      const { attrs } = data
23 1
      if (attrs) {
24
        // reset attrs to extract utility clases like pa-3
25 1
        data.attrs = {}
26 1
        const classes = Object.keys(attrs).filter(key => {
27
          // TODO: Remove once resolved
28
          // https://github.com/vuejs/vue/issues/7841
29 1
          if (key === 'slot') return false
30

31 1
          const value = attrs[key]
32

33
          // add back data attributes like data-test="foo" but do not
34
          // add them as classes
35 1
          if (key.startsWith('data-')) {
36 1
            data.attrs![key] = value
37 1
            return false
38
          }
39

40 1
          return value || typeof value === 'string'
41
        })
42

43 1
        if (classes.length) data.staticClass += ` ${classes.join(' ')}`
44
      }
45

46 1
      if (props.id) {
47 1
        data.domProps = data.domProps || {}
48 1
        data.domProps.id = props.id
49
      }
50

51 1
      return h(props.tag, data, children)
52
    },
53
  })
54
}

Read our documentation on viewing source code .

Loading