8000 add reject fn to async component factory · Snoopbobb/vue@ba89647 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba89647

Browse files
committed
add reject fn to async component factory
1 parent 4e83218 commit ba89647

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/instance/misc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ exports._resolveComponent = function (id, cb) {
5757
// cached
5858
cb(factory.resolved)
5959
} else if (factory.requested) {
60+
// pool callbacks
6061
factory.pendingCallbacks.push(cb)
6162
} else {
6263
factory.requested = true
@@ -71,6 +72,11 @@ exports._resolveComponent = function (id, cb) {
7172
for (var i = 0, l = cbs.length; i < l; i++) {
7273
cbs[i](res)
7374
}
75+
}, function reject (reason) {
76+
_.warn(
77+
'Failed to resolve async component: ' + id + '. ' +
78+
(reason ? '\nReason: ' + reason : '')
79+
)
7480
})
7581
}
7682
} else {

test/unit/specs/async_component_spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ describe('Async components', function () {
182182
done()
183183
}
184184
})
185+
186+
it('warn reject', function () {
187+
var vm = new Vue({
188+
el: el,
189+
template: '<test></test>',
190+
components: {
191+
test: function (resolve, reject) {
192+
reject('nooooo')
193+
}
194+
}
195+
})
196+
expect(hasWarned(_, 'Reason: nooooo')).toBe(true)
197+
})
185198
})
186199

187200
describe('v-repeat', function () {

0 commit comments

Comments
 (0)
0