Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
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 |
data.staticClass = (`${name} ${data.staticClass || ''}`).trim() |
|
21 |
|
|
22 | 1 |
const { attrs } = data |
23 |
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 |
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 |
if (key.startsWith('data-')) { |
|
36 | 1 |
data.attrs![key] = value |
37 | 1 |
return false |
38 |
}
|
|
39 |
|
|
40 |
return value || typeof value === 'string' |
|
41 |
})
|
|
42 |
|
|
43 |
if (classes.length) data.staticClass += ` ${classes.join(' ')}` |
|
44 |
}
|
|
45 |
|
|
46 |
if (props.id) { |
|
47 |
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 .