File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ export default class Wrapper implements BaseWrapper {
237237 */
238238 findComponent ( rawSelector : Selector ) : Wrapper | ErrorWrapper {
239239 const selector = getSelector ( rawSelector , 'findComponent' )
240- if ( ! this . vm ) {
240+ if ( ! this . vm && ! this . isFunctionalComponent ) {
241241 throwError (
242242 'You cannot chain findComponent off a DOM element. It can only be used on Vue Components.'
243243 )
Original file line number Diff line number Diff line change @@ -162,6 +162,18 @@ describeWithShallowAndMount('find', mountingMethod => {
162162 . with . property ( 'message' , message )
163163 } )
164164
165+ it ( 'allows using findComponent on functional component' , ( ) => {
166+ const FuncComponentWithChildren = {
167+ functional : true ,
168+ components : {
169+ ChildComponent : Component
170+ } ,
171+ render : h => h ( 'div' , { } , [ h ( Component ) ] )
172+ }
173+ const wrapper = mountingMethod ( FuncComponentWithChildren )
174+ expect ( wrapper . findComponent ( Component ) . exists ( ) ) . to . be . true
175+ } )
176+
165177 itSkipIf ( isRunningPhantomJS , 'returns Wrapper of class component' , ( ) => {
166178 const TestComponent = {
167179 template : `
You can’t perform that action at this time.
0 commit comments