Skip to content

Commit 71ec3b9

Browse files
authored
fix: do not remove cached constructors (#962)
* fix: do not removed cached constructors * test: fix linting error
1 parent 88ffc98 commit 71ec3b9

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

Diff for: packages/create-instance/create-instance.js

-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ export default function createInstance (
3838
options: Options,
3939
_Vue: Component
4040
): Component {
41-
// Remove cached constructor
42-
delete component._Ctor
43-
4441
// make sure all extends are based on this instance
4542
_Vue.options._base = _Vue
4643

Diff for: packages/server-test-utils/src/renderToString.js

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ export default function renderToString (
2222
`renderToString must be run in node. It cannot be ` + `run in a browser`
2323
)
2424
}
25-
// Remove cached constructor
26-
delete component._Ctor
2725

2826
if (options.attachToDocument) {
2927
throwError(`you cannot use attachToDocument with ` + `renderToString`)

Diff for: packages/shared/create-component-stubs.js

-7
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ export function createStubsFromStubsObject (
149149
return acc
150150
}
151151

152-
if (originalComponents[stubName]) {
153-
// Remove cached constructor
154-
delete originalComponents[stubName]._Ctor
155-
}
156-
157152
if (typeof stub === 'string') {
158153
acc[stubName] = createStubFromString(
159154
stub,
@@ -195,8 +190,6 @@ function stubComponents (
195190
)
196191
return
197192
}
198-
// Remove cached constructor
199-
delete componentOptions._Ctor
200193

201194
stubbedComponents[component] = createStubFromComponent(
202195
cmp,

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

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ export default function mount (
2525

2626
warnIfNoWindow()
2727

28-
// Remove cached constructor
29-
delete component._Ctor
30-
3128
const elm = options.attachToDocument ? createElement() : undefined
3229

3330
const mergedOptions = mergeOptions(options, config)

Diff for: test/specs/wrapper/find.spec.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,23 @@ describeWithShallowAndMount('find', mountingMethod => {
291291
expect(wrapper.find(Component).vnode).to.be.an('object')
292292
})
293293

294-
it('returns array of VueWrappers of Vue Components matching component if component name in parent is different to filename', () => {
294+
it('returns Wrapper matching selector using Wrapper as reference', () => {
295295
const wrapper = mountingMethod(ComponentWithChild)
296296
const div = wrapper.find('span')
297297
expect(div.find(Component).vnode).to.be.an('object')
298298
})
299299

300-
it('returns Wrapper matching selector using Wrapper as reference', () => {
301-
const wrapper = mountingMethod(ComponentWithChild)
302-
const div = wrapper.find('span')
303-
expect(div.find(Component).vnode).to.be.an('object')
300+
it('selector works between mounts', () => {
301+
const ChildComponent = { template: '<div />' }
302+
const TestComponent = {
303+
template: '<child-component />',
304+
components: {
305+
ChildComponent
306+
}
307+
}
308+
const wrapper = mountingMethod(TestComponent)
309+
mountingMethod(ChildComponent)
310+
expect(wrapper.find(ChildComponent).vnode).to.be.an('object')
304311
})
305312

306313
it('returns error Wrapper if Vue component is below Wrapper', () => {

0 commit comments

Comments
 (0)