1
- var _ = require ( '../../util' )
2
1
import { cloneNode } from '../../parsers/template'
2
+ import {
3
+ extractContent ,
4
+ createAnchor ,
5
+ replace ,
6
+ hyphenate ,
7
+ warn ,
8
+ cancellable ,
9
+ extend
10
+ } from '../../util'
3
11
4
- module . exports = {
12
+ export default {
5
13
6
14
priority : 1500 ,
7
15
@@ -21,7 +29,7 @@ module.exports = {
21
29
* <component :is="view">
22
30
*/
23
31
24
- bind : function ( ) {
32
+ bind ( ) {
25
33
if ( ! this . el . __vue__ ) {
26
34
// keep-alive cache
27
35
this . keepAlive = this . params . keepAlive
@@ -31,7 +39,7 @@ module.exports = {
31
39
// check inline-template
32
40
if ( this . params . inlineTemplate ) {
33
41
// extract inline template as a DocumentFragment
34
- this . inlineTemplate = _ . extractContent ( this . el , true )
42
+ this . inlineTemplate = extractContent ( this . el , true )
35
43
}
36
44
// component resolution related state
37
45
this . pendingComponentCb =
@@ -40,23 +48,23 @@ module.exports = {
40
48
this . pendingRemovals = 0
41
49
this . pendingRemovalCb = null
42
50
// create a ref anchor
43
- this . anchor = _ . createAnchor ( 'v-component' )
44
- _ . replace ( this . el , this . anchor )
51
+ this . anchor = createAnchor ( 'v-component' )
52
+ replace ( this . el , this . anchor )
45
53
// remove is attribute.
46
54
// this is removed during compilation, but because compilation is
47
55
// cached, when the component is used elsewhere this attribute
48
56
// will remain at link time.
49
57
this . el . removeAttribute ( 'is' )
50
58
// remove ref, same as above
51
59
if ( this . descriptor . ref ) {
52
- this . el . removeAttribute ( 'v-ref:' + _ . hyphenate ( this . descriptor . ref ) )
60
+ this . el . removeAttribute ( 'v-ref:' + hyphenate ( this . descriptor . ref ) )
53
61
}
54
62
// if static, build right now.
55
63
if ( this . literal ) {
56
64
this . setComponent ( this . expression )
57
65
}
58
66
} else {
59
- process . env . NODE_ENV !== 'production' && _ . warn (
67
+ process . env . NODE_ENV !== 'production' && warn (
60
68
'cannot mount component "' + this . expression + '" ' +
61
69
'on already mounted element: ' + this . el
62
70
)
@@ -68,7 +76,7 @@ module.exports = {
68
76
* literal scenario, e.g. <component :is="view">
69
77
*/
70
78
71
- update : function ( value ) {
79
+ update ( value ) {
72
80
if ( ! this . literal ) {
73
81
this . setComponent ( value )
74
82
}
@@ -87,7 +95,7 @@ module.exports = {
87
95
* @param {Function } [cb]
88
96
*/
89
97
90
- setComponent : function ( value , cb ) {
98
+ setComponent ( value , cb ) {
91
99
this . invalidatePending ( )
92
100
if ( ! value ) {
93
101
// just remove current
@@ -107,9 +115,9 @@ module.exports = {
107
115
* the child vm.
108
116
*/
109
117
110
- resolveComponent : function ( id , cb ) {
118
+ resolveComponent ( id , cb ) {
111
119
var self = this
112
- this . pendingComponentCb = _ . cancellable ( function ( Component ) {
120
+ this . pendingComponentCb = cancellable ( function ( Component ) {
113
121
self . ComponentName = Component . options . name || id
114
122
self . Component = Component
115
123
cb ( )
@@ -126,7 +134,7 @@ module.exports = {
126
134
* @param {Function } [cb]
127
135
*/
128
136
129
- mountComponent : function ( cb ) {
137
+ mountComponent ( cb ) {
130
138
// actual mount
131
139
this . unbuild ( true )
132
140
var self = this
@@ -154,7 +162,7 @@ module.exports = {
154
162
* pending callback.
155
163
*/
156
164
157
- invalidatePending : function ( ) {
165
+ invalidatePending ( ) {
158
166
if ( this . pendingComponentCb ) {
159
167
this . pendingComponentCb . cancel ( )
160
168
this . pendingComponentCb = null
@@ -170,7 +178,7 @@ module.exports = {
170
178
* @return {Vue } - the created instance
171
179
*/
172
180
173
- build : function ( extraOptions ) {
181
+ build ( extraOptions ) {
174
182
var cached = this . getCached ( )
175
183
if ( cached ) {
176
184
return cached
@@ -210,7 +218,7 @@ module.exports = {
210
218
// in 1.0.0 this is used by vue-router only
211
219
/* istanbul ignore if */
212
220
if ( extraOptions ) {
213
- _ . extend ( options , extraOptions )
221
+ extend ( options , extraOptions )
214
222
}
215
223
var child = new this . Component ( options )
216
224
if ( this . keepAlive ) {
@@ -220,7 +228,7 @@ module.exports = {
220
228
if ( process . env . NODE_ENV !== 'production' &&
221
229
this . el . hasAttribute ( 'transition' ) &&
222
230
child . _isFragment ) {
223
- _ . warn (
231
+ warn (
224
232
'Transitions will not work on a fragment instance. ' +
225
233
'Template: ' + child . $options . template
226
234
)
@@ -235,7 +243,7 @@ module.exports = {
235
243
* @return {Vue|undefined }
236
244
*/
237
245
238
- getCached : function ( ) {
246
+ getCached ( ) {
239
247
return this . keepAlive && this . cache [ this . Component . cid ]
240
248
} ,
241
249
@@ -246,7 +254,7 @@ module.exports = {
246
254
* @param {Boolean } defer
247
255
*/
248
256
249
- unbuild : function ( defer ) {
257
+ unbuild ( defer ) {
250
258
if ( this . waitingFor ) {
251
259
this . waitingFor . $destroy ( )
252
260
this . waitingFor = null
@@ -272,7 +280,7 @@ module.exports = {
272
280
* @param {Function } cb
273
281
*/
274
282
275
- remove : function ( child , cb ) {
283
+ remove ( child , cb ) {
276
284
var keepAlive = this . keepAlive
277
285
if ( child ) {
278
286
// we may have a component switch when a previous
@@ -303,7 +311,7 @@ module.exports = {
303
311
* @param {Function } [cb]
304
312
*/
305
313
306
- transition : function ( target , cb ) {
314
+ transition ( target , cb ) {
307
315
var self = this
308
316
var current = this . childVM
309
317
// for devtool inspection
@@ -333,7 +341,7 @@ module.exports = {
333
341
* Unbind.
334
342
*/
335
343
336
- unbind : function ( ) {
344
+ unbind ( ) {
337
345
this . invalidatePending ( )
338
346
// Do not defer cleanup when unbinding
339
347
this . unbuild ( )
0 commit comments