Browse Source

improved resolving mechanism for resolved components

dev
Blake Newman 9 years ago
parent
commit
916bbfd766
  1. 11
      src/core/vdom/create-component.js

11
src/core/vdom/create-component.js

@ -113,24 +113,27 @@ function destroy (vnode) {
function resolveAsyncComponent (factory, cb) {
if (factory.resolved) {
// cached
cb(factory.resolved)
return factory.resolved
} else if (factory.requested) {
// pool callbacks
factory.pendingCallbacks.push(cb)
} else {
factory.requested = true
const cbs = factory.pendingCallbacks = [cb]
return factory(function resolve (res) {
factory.resolved = factory(function resolve (res) {
if (isObject(res)) {
res = Vue.extend(res)
}
// cache resolved
factory.resolved = res
// invoke callbacks
for (let i = 0, l = cbs.length; i < l; i++) {
cbs[i](res)
// Reset pending callbacks
factory.pendingCallbacks = []
}
return res
}, function reject (reason) {
process.env.NODE_ENV !== 'production' && warn(
@ -138,7 +141,9 @@ function resolveAsyncComponent (factory, cb) {
(reason ? `\nReason: ${reason}` : '')
)
})
return factory.resolved
}
}
function extractProps (data, Ctor) {

Loading…
Cancel
Save