Skip to content

Commit 45a1992

Browse files
committed
remove replaceBindingComponent()
1 parent fc7b713 commit 45a1992

File tree

3 files changed

+4
-35
lines changed

3 files changed

+4
-35
lines changed

Diff for: packages/test-utils/src/find-vue-components.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,7 @@ export function vmFunctionalCtorMatchesSelector (
9090
return Ctors.some(c => Ctor[c] === component[FUNCTIONAL_OPTIONS]._Ctor[c])
9191
}
9292

93-
export function findVueComponentByElement (
94-
vm: Component,
95-
elem: Element
96-
): ?Component {
97-
const components = findAllVueComponentsFromVm(vm)
98-
for (let i = 0, max = components.length; i < max; i++) {
99-
const component = components[i]
100-
if (component.$el === elem) {
101-
return component
102-
}
103-
}
104-
}
105-
106-
export function findVueComponents (
93+
export default function findVueComponents (
10794
root: Component,
10895
selectorType: ?string,
10996
selector: Object

Diff for: packages/test-utils/src/find.js

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
11
// @flow
22

33
import findVnodes from './find-vnodes'
4-
import {
5-
findVueComponents,
6-
findVueComponentByElement
7-
} from './find-vue-components'
4+
import findVueComponents from './find-vue-components'
85
import findDOMNodes from './find-dom-nodes'
96
import { COMPONENT_SELECTOR, NAME_SELECTOR, DOM_SELECTOR } from './consts'
107
import Vue from 'vue'
118
import getSelectorTypeOrThrow from './get-selector-type'
129
import { throwError } from 'shared/util'
1310

14-
// Returns a component if the element binds a Vue instance.
15-
function replaceBindingComponent (vnode: VNode): VNode | Component {
16-
if (vnode.elm && vnode.elm.__vue__) {
17-
const component =
18-
findVueComponentByElement(vnode.elm.__vue__.$root, vnode.elm)
19-
if (component) {
20-
return component
21-
}
22-
}
23-
return vnode
24-
}
25-
2611
export default function find (
2712
vm: Component | null,
2813
vnode: VNode | null,
@@ -58,14 +43,11 @@ export default function find (
5843

5944
if (vnode) {
6045
const nodes = findVnodes(vnode, vm, selectorType, selector)
61-
.map(replaceBindingComponent)
6246
if (selectorType !== DOM_SELECTOR) {
6347
return nodes
6448
}
6549
return nodes.length > 0 ? nodes : findDOMNodes(element, selector)
66-
.map(replaceBindingComponent)
6750
}
6851

6952
return findDOMNodes(element, selector)
70-
.map(replaceBindingComponent)
7153
}

Diff for: packages/test-utils/src/wrapper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export default class Wrapper implements BaseWrapper {
325325
}
326326
// Using CSS Selector, returns a VueWrapper instance if the root element
327327
// binds a Vue instance.
328-
if (nodes[0].$el === this.element && nodes[0].$parent === undefined) {
328+
if (nodes[0].elm === this.element) {
329329
return this
330330
}
331331
return createWrapper(nodes[0], this.options)
@@ -341,7 +341,7 @@ export default class Wrapper implements BaseWrapper {
341341
const wrappers = nodes.map(node => {
342342
// Using CSS Selector, returns a VueWrapper instance if the root element
343343
// binds a Vue instance.
344-
return node.$el === this.element && node.$parent === undefined
344+
return node.elm === this.element
345345
? this
346346
: createWrapper(node, this.options)
347347
})

0 commit comments

Comments
 (0)