-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpartial.js
49 lines (42 loc) · 957 Bytes
/
partial.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import vIf from '../public/if'
import FragmentFactory from '../../fragment/factory'
import { PARTIAL } from '../priorities'
import {
createAnchor,
replace,
resolveAsset,
assertAsset
} from '../../util/index'
export default {
priority: PARTIAL,
params: ['name'],
// watch changes to name for dynamic partials
paramWatchers: {
name (value) {
vIf.remove.call(this)
if (value) {
this.insert(value)
}
}
},
bind () {
this.anchor = createAnchor('v-partial')
replace(this.el, this.anchor)
this.insert(this.params.name)
},
insert (id) {
var partial = resolveAsset(this.vm.$options, 'partials', id)
if (process.env.NODE_ENV !== 'production') {
assertAsset(partial, 'partial', id)
}
if (partial) {
this.factory = new FragmentFactory(this.vm, partial)
vIf.insert.call(this)
}
},
unbind () {
if (this.frag) {
this.frag.destroy()
}
}
}