File tree 2 files changed +23
-8
lines changed
2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ function vmMatchesName(vm, name) {
10
10
// We want to mirror how Vue resolves component names in SFCs:
11
11
// For example, <test-component />, <TestComponent /> and `<testComponent />
12
12
// all resolve to the same component
13
- const componentName = ( vm . $options && vm . $options . name ) || ''
13
+ const componentName = vm . name || ( vm . $options && vm . $options . name ) || ''
14
14
return (
15
15
! ! name &&
16
16
( componentName === name ||
@@ -56,13 +56,7 @@ export function matches(node, selector) {
56
56
return element && element . matches && element . matches ( selector . value )
57
57
}
58
58
59
- const isFunctionalSelector = isConstructor ( selector . value )
60
- ? selector . value . options . functional
61
- : selector . value . functional
62
-
63
- const componentInstance = isFunctionalSelector
64
- ? node [ FUNCTIONAL_OPTIONS ]
65
- : node . child
59
+ const componentInstance = node [ FUNCTIONAL_OPTIONS ] || node . child
66
60
67
61
if ( ! componentInstance ) {
68
62
return false
Original file line number Diff line number Diff line change @@ -257,6 +257,27 @@ describeWithShallowAndMount('find', mountingMethod => {
257
257
}
258
258
} )
259
259
260
+ it ( 'returns functional component with name by name' , ( ) => {
261
+ if ( vueVersion < 2.3 ) {
262
+ return
263
+ }
264
+ const TestFunctionalComponent = {
265
+ render : h => h ( 'div' ) ,
266
+ functional : true ,
267
+ name : 'test-functional-component'
268
+ }
269
+ const TestComponent = {
270
+ template : '<div><test-functional-component /></div>' ,
271
+ components : {
272
+ TestFunctionalComponent
273
+ }
274
+ }
275
+ const wrapper = mountingMethod ( TestComponent )
276
+ expect (
277
+ wrapper . find ( { name : 'test-functional-component' } ) . exists ( )
278
+ ) . toEqual ( true )
279
+ } )
280
+
260
281
it ( 'returns extended functional component' , ( ) => {
261
282
const TestFunctionalComponent = Vue . extend ( {
262
283
render : h => h ( 'div' ) ,
You can’t perform that action at this time.
0 commit comments