Skip to content

Commit 6c51c0a

Browse files
committed
do not throw when component is not found (close #1099)
1 parent 3483db2 commit 6c51c0a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/instance/misc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ exports._resolveComponent = function (id, cb) {
5555
if (process.env.NODE_ENV !== 'production') {
5656
_.assertAsset(factory, 'component', id)
5757
}
58+
if (!factory) {
59+
return
60+
}
5861
// async component factory
5962
if (!factory.options) {
6063
if (factory.resolved) {

test/unit/specs/directives/component_spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,5 +423,14 @@ if (_.inBrowser) {
423423
expect(hasWarned(_, 'cannot mount component "test" on already mounted element')).toBe(true)
424424
})
425425

426+
it('not found component should not throw', function () {
427+
expect(function () {
428+
new Vue({
429+
el: el,
430+
template: '<div v-component="non-existent"></div>'
431+
})
432+
}).not.toThrow()
433+
})
434+
426435
})
427436
}

0 commit comments

Comments
 (0)