mirror of https://github.com/vuejs/vue.git
better naming for internals
This commit is contained in:
parent
9f37925602
commit
563b063eb7
|
|
@ -41,11 +41,11 @@ module.exports = {
|
|||
}
|
||||
// component resolution related state
|
||||
this._pendingCb =
|
||||
this.ctorId =
|
||||
this.Ctor = null
|
||||
this.componentID =
|
||||
this.Component = null
|
||||
// if static, build right now.
|
||||
if (!this._isDynamicLiteral) {
|
||||
this.resolveCtor(this.expression, _.bind(this.initStatic, this))
|
||||
this.resolveComponent(this.expression, _.bind(this.initStatic, this))
|
||||
} else {
|
||||
// check dynamic component params
|
||||
this.transMode = this._checkParam('transition-mode')
|
||||
|
|
@ -104,7 +104,7 @@ module.exports = {
|
|||
this.remove(this.childVM, afterTransition)
|
||||
this.unsetCurrent()
|
||||
} else {
|
||||
this.resolveCtor(value, _.bind(function () {
|
||||
this.resolveComponent(value, _.bind(function () {
|
||||
this.unbuild(true)
|
||||
var newComponent = this.build(data)
|
||||
/* istanbul ignore if */
|
||||
|
|
@ -126,11 +126,11 @@ module.exports = {
|
|||
* the child vm.
|
||||
*/
|
||||
|
||||
resolveCtor: function (id, cb) {
|
||||
resolveComponent: function (id, cb) {
|
||||
var self = this
|
||||
this._pendingCb = _.cancellable(function (ctor) {
|
||||
self.ctorId = id
|
||||
self.Ctor = ctor
|
||||
this._pendingCb = _.cancellable(function (component) {
|
||||
self.componentID = id
|
||||
self.Component = component
|
||||
cb()
|
||||
})
|
||||
this.vm._resolveComponent(id, this._pendingCb)
|
||||
|
|
@ -160,12 +160,12 @@ module.exports = {
|
|||
|
||||
build: function (data) {
|
||||
if (this.keepAlive) {
|
||||
var cached = this.cache[this.ctorId]
|
||||
var cached = this.cache[this.componentID]
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
}
|
||||
if (this.Ctor) {
|
||||
if (this.Component) {
|
||||
var parent = this._host || this.vm
|
||||
var el = templateParser.clone(this.el)
|
||||
var child = parent.$addChild({
|
||||
|
|
@ -178,9 +178,9 @@ module.exports = {
|
|||
_asComponent: true,
|
||||
_isRouterView: this._isRouterView,
|
||||
_context: this.vm
|
||||
}, this.Ctor)
|
||||
}, this.Component)
|
||||
if (this.keepAlive) {
|
||||
this.cache[this.ctorId] = child
|
||||
this.cache[this.componentID] = child
|
||||
}
|
||||
return child
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ module.exports = {
|
|||
var id = _.checkComponent(this.el, options)
|
||||
if (!id) {
|
||||
// default constructor
|
||||
this.Ctor = _.Vue
|
||||
this.Component = _.Vue
|
||||
// inline repeats should inherit
|
||||
this.inline = true
|
||||
// important: transclude with no options, just
|
||||
|
|
@ -109,7 +109,7 @@ module.exports = {
|
|||
copy._asComponent = false
|
||||
this._linkFn = compiler.compile(this.template, copy)
|
||||
} else {
|
||||
this.Ctor = null
|
||||
this.Component = null
|
||||
this.asComponent = true
|
||||
// check inline-template
|
||||
if (this._checkParam('inline-template') !== null) {
|
||||
|
|
@ -119,8 +119,8 @@ module.exports = {
|
|||
var tokens = textParser.parse(id)
|
||||
if (tokens) {
|
||||
// dynamic component to be resolved later
|
||||
var ctorExp = textParser.tokensToExp(tokens)
|
||||
this.ctorGetter = expParser.parse(ctorExp).get
|
||||
var componentExp = textParser.tokensToExp(tokens)
|
||||
this.componentGetter = expParser.parse(componentExp).get
|
||||
} else {
|
||||
// static
|
||||
this.componentId = id
|
||||
|
|
@ -131,11 +131,11 @@ module.exports = {
|
|||
|
||||
resolveComponent: function () {
|
||||
this.componentState = PENDING
|
||||
this.vm._resolveComponent(this.componentId, _.bind(function (Ctor) {
|
||||
this.vm._resolveComponent(this.componentId, _.bind(function (Component) {
|
||||
if (this.componentState === ABORTED) {
|
||||
return
|
||||
}
|
||||
this.Ctor = Ctor
|
||||
this.Component = Component
|
||||
this.componentState = RESOLVED
|
||||
this.realUpdate(this.pendingData)
|
||||
this.pendingData = null
|
||||
|
|
@ -165,19 +165,19 @@ module.exports = {
|
|||
for (key in meta) {
|
||||
_.define(context, key, meta[key])
|
||||
}
|
||||
var id = this.ctorGetter.call(context, context)
|
||||
var Ctor = _.resolveAsset(this.vm.$options, 'components', id)
|
||||
var id = this.componentGetter.call(context, context)
|
||||
var Component = _.resolveAsset(this.vm.$options, 'components', id)
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
_.assertAsset(Ctor, 'component', id)
|
||||
_.assertAsset(Component, 'component', id)
|
||||
}
|
||||
if (!Ctor.options) {
|
||||
if (!Component.options) {
|
||||
process.env.NODE_ENV !== 'production' && _.warn(
|
||||
'Async resolution is not supported for v-repeat ' +
|
||||
'+ dynamic component. (component: ' + id + ')'
|
||||
)
|
||||
return _.Vue
|
||||
}
|
||||
return Ctor
|
||||
return Component
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -359,7 +359,7 @@ module.exports = {
|
|||
data = raw
|
||||
}
|
||||
// resolve constructor
|
||||
var Ctor = this.Ctor || this.resolveDynamicComponent(data, meta)
|
||||
var Component = this.Component || this.resolveDynamicComponent(data, meta)
|
||||
var parent = this._host || this.vm
|
||||
var vm = parent.$addChild({
|
||||
el: templateParser.clone(this.template),
|
||||
|
|
@ -373,14 +373,14 @@ module.exports = {
|
|||
// is this a component?
|
||||
_asComponent: this.asComponent,
|
||||
// linker cachable if no inline-template
|
||||
_linkerCachable: !this.inlineTemplate && Ctor !== _.Vue,
|
||||
_linkerCachable: !this.inlineTemplate && Component !== _.Vue,
|
||||
// pre-compiled linker for simple repeats
|
||||
_linkFn: this._linkFn,
|
||||
// identifier, shows that this vm belongs to this collection
|
||||
_repeatId: this.id,
|
||||
// transclusion content owner
|
||||
_context: this.vm
|
||||
}, Ctor)
|
||||
}, Component)
|
||||
// cache instance
|
||||
if (needCache) {
|
||||
this.cacheVm(raw, vm, index, this.converted ? meta.$key : null)
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ describe('Async components', function () {
|
|||
function step1 () {
|
||||
// called after A resolves, but A should have been
|
||||
// invalidated so not cotrId should be set
|
||||
expect(vm._directives[0].ctorId).toBe(null)
|
||||
expect(vm._directives[0].componentID).toBe(null)
|
||||
}
|
||||
function step2 () {
|
||||
// B should resolve successfully
|
||||
|
|
@ -146,7 +146,7 @@ describe('Async components', function () {
|
|||
function next () {
|
||||
// called after A resolves, but A should have been
|
||||
// invalidated so not cotrId should be set
|
||||
expect(dir.ctorId).toBe(null)
|
||||
expect(dir.componentID).toBe(null)
|
||||
done()
|
||||
}
|
||||
})
|
||||
|
|
@ -282,7 +282,7 @@ describe('Async components', function () {
|
|||
vm.$destroy()
|
||||
function next () {
|
||||
expect(el.textContent).toBe('')
|
||||
expect(dir.Ctor).toBe(null)
|
||||
expect(dir.Component).toBe(null)
|
||||
done()
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue