Skip to content

Commit 82767a0

Browse files
committed
support using actual component constructors in :is
1 parent 158d6d5 commit 82767a0

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/directives/internal/component.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,17 @@ export default {
118118

119119
resolveComponent (id, cb) {
120120
var self = this
121-
this.pendingComponentCb = cancellable(function (Component) {
121+
var done = function (Component) {
122122
self.ComponentName = Component.options.name || id
123123
self.Component = Component
124124
cb()
125-
})
126-
this.vm._resolveComponent(id, this.pendingComponentCb)
125+
}
126+
if (typeof id === 'function') {
127+
done(id)
128+
} else {
129+
this.pendingComponentCb = cancellable(done)
130+
this.vm._resolveComponent(id, this.pendingComponentCb)
131+
}
127132
},
128133

129134
/**

test/unit/specs/directives/internal/component_spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,19 @@ describe('Component', function () {
134134
})
135135
})
136136

137+
it(':is using raw component constructor', function () {
138+
new Vue({
139+
el: el,
140+
template: '<component :is="$options.components.test">',
141+
components: {
142+
test: {
143+
template: 'hi'
144+
}
145+
}
146+
})
147+
expect(el.textContent).toBe('hi')
148+
})
149+
137150
it('keep-alive', function (done) {
138151
var spyA = jasmine.createSpy()
139152
var spyB = jasmine.createSpy()

0 commit comments

Comments
 (0)