Skip to content

Commit e928b56

Browse files
Merge branch 'vuejs:dev' into translate-to-portuguese
2 parents 2be0f80 + a989458 commit e928b56

File tree

10 files changed

+101
-76
lines changed

10 files changed

+101
-76
lines changed

Diff for: lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
],
66
"npmClient": "yarn",
77
"useWorkspaces": true,
8-
"version": "1.3.5"
8+
"version": "1.3.6"
99
}

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

+11-13
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,8 @@ function getScopedSlotRenderFunctions(ctx: any): Array<string> {
7777
// In Vue 2.6+ a new v-slot syntax was introduced
7878
// scopedSlots are now saved in parent._vnode.data.scopedSlots
7979
// We filter out _normalized, $stable and $key keys
80-
if (
81-
ctx &&
82-
ctx.$options &&
83-
ctx.$options.parent &&
84-
ctx.$options.parent._vnode &&
85-
ctx.$options.parent._vnode.data &&
86-
ctx.$options.parent._vnode.data.scopedSlots
87-
) {
88-
const slotKeys: Array<string> = ctx.$options.parent._vnode.data.scopedSlots
89-
return keys(slotKeys).filter(
80+
if (ctx.$vnode.data.scopedSlots) {
81+
return keys(ctx.$vnode.data.scopedSlots).filter(
9082
x => x !== '_normalized' && x !== '$stable' && x !== '$key'
9183
)
9284
}
@@ -130,9 +122,15 @@ export function createStubFromComponent(
130122
context
131123
? context.children
132124
: this.$options._renderChildren ||
133-
getScopedSlotRenderFunctions(this).map(x =>
134-
this.$options.parent._vnode.data.scopedSlots[x]({})
135-
)
125+
getScopedSlotRenderFunctions(this)
126+
.map(x => {
127+
let result = null
128+
try {
129+
result = this.$vnode.data.scopedSlots[x]({})
130+
} catch (e) {}
131+
return result
132+
})
133+
.filter(Boolean)
136134
)
137135
}
138136
}

Diff for: packages/server-test-utils/dist/vue-server-test-utils.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -13507,16 +13507,8 @@ function getScopedSlotRenderFunctions(ctx) {
1350713507
// In Vue 2.6+ a new v-slot syntax was introduced
1350813508
// scopedSlots are now saved in parent._vnode.data.scopedSlots
1350913509
// We filter out _normalized, $stable and $key keys
13510-
if (
13511-
ctx &&
13512-
ctx.$options &&
13513-
ctx.$options.parent &&
13514-
ctx.$options.parent._vnode &&
13515-
ctx.$options.parent._vnode.data &&
13516-
ctx.$options.parent._vnode.data.scopedSlots
13517-
) {
13518-
var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
13519-
return keys$1(slotKeys).filter(
13510+
if (ctx.$vnode.data.scopedSlots) {
13511+
return keys$1(ctx.$vnode.data.scopedSlots).filter(
1352013512
function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
1352113513
)
1352213514
}
@@ -13555,8 +13547,15 @@ function createStubFromComponent(
1355513547
context
1355613548
? context.children
1355713549
: this.$options._renderChildren ||
13558-
getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
13559-
)
13550+
getScopedSlotRenderFunctions(this)
13551+
.map(function (x) {
13552+
var result = null;
13553+
try {
13554+
result = this$1.$vnode.data.scopedSlots[x]({});
13555+
} catch (e) {}
13556+
return result
13557+
})
13558+
.filter(Boolean)
1356013559
)
1356113560
}})
1356213561
}

Diff for: packages/server-test-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/server-test-utils",
3-
"version": "1.3.5",
3+
"version": "1.3.6",
44
"description": "Utilities for testing Vue components.",
55
"main": "dist/vue-server-test-utils.js",
66
"types": "types/index.d.ts",

Diff for: packages/test-utils/dist/vue-test-utils.esm.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -2295,16 +2295,8 @@ function getScopedSlotRenderFunctions(ctx) {
22952295
// In Vue 2.6+ a new v-slot syntax was introduced
22962296
// scopedSlots are now saved in parent._vnode.data.scopedSlots
22972297
// We filter out _normalized, $stable and $key keys
2298-
if (
2299-
ctx &&
2300-
ctx.$options &&
2301-
ctx.$options.parent &&
2302-
ctx.$options.parent._vnode &&
2303-
ctx.$options.parent._vnode.data &&
2304-
ctx.$options.parent._vnode.data.scopedSlots
2305-
) {
2306-
var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
2307-
return keys(slotKeys).filter(
2298+
if (ctx.$vnode.data.scopedSlots) {
2299+
return keys(ctx.$vnode.data.scopedSlots).filter(
23082300
function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
23092301
)
23102302
}
@@ -2343,8 +2335,15 @@ function createStubFromComponent(
23432335
context
23442336
? context.children
23452337
: this.$options._renderChildren ||
2346-
getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
2347-
)
2338+
getScopedSlotRenderFunctions(this)
2339+
.map(function (x) {
2340+
var result = null;
2341+
try {
2342+
result = this$1.$vnode.data.scopedSlots[x]({});
2343+
} catch (e) {}
2344+
return result
2345+
})
2346+
.filter(Boolean)
23482347
)
23492348
}})
23502349
}

Diff for: packages/test-utils/dist/vue-test-utils.iife.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -2299,16 +2299,8 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
22992299
// In Vue 2.6+ a new v-slot syntax was introduced
23002300
// scopedSlots are now saved in parent._vnode.data.scopedSlots
23012301
// We filter out _normalized, $stable and $key keys
2302-
if (
2303-
ctx &&
2304-
ctx.$options &&
2305-
ctx.$options.parent &&
2306-
ctx.$options.parent._vnode &&
2307-
ctx.$options.parent._vnode.data &&
2308-
ctx.$options.parent._vnode.data.scopedSlots
2309-
) {
2310-
var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
2311-
return keys(slotKeys).filter(
2302+
if (ctx.$vnode.data.scopedSlots) {
2303+
return keys(ctx.$vnode.data.scopedSlots).filter(
23122304
function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
23132305
)
23142306
}
@@ -2347,8 +2339,15 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
23472339
context
23482340
? context.children
23492341
: this.$options._renderChildren ||
2350-
getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
2351-
)
2342+
getScopedSlotRenderFunctions(this)
2343+
.map(function (x) {
2344+
var result = null;
2345+
try {
2346+
result = this$1.$vnode.data.scopedSlots[x]({});
2347+
} catch (e) {}
2348+
return result
2349+
})
2350+
.filter(Boolean)
23522351
)
23532352
}})
23542353
}

Diff for: packages/test-utils/dist/vue-test-utils.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -2303,16 +2303,8 @@ function getScopedSlotRenderFunctions(ctx) {
23032303
// In Vue 2.6+ a new v-slot syntax was introduced
23042304
// scopedSlots are now saved in parent._vnode.data.scopedSlots
23052305
// We filter out _normalized, $stable and $key keys
2306-
if (
2307-
ctx &&
2308-
ctx.$options &&
2309-
ctx.$options.parent &&
2310-
ctx.$options.parent._vnode &&
2311-
ctx.$options.parent._vnode.data &&
2312-
ctx.$options.parent._vnode.data.scopedSlots
2313-
) {
2314-
var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
2315-
return keys(slotKeys).filter(
2306+
if (ctx.$vnode.data.scopedSlots) {
2307+
return keys(ctx.$vnode.data.scopedSlots).filter(
23162308
function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
23172309
)
23182310
}
@@ -2351,8 +2343,15 @@ function createStubFromComponent(
23512343
context
23522344
? context.children
23532345
: this.$options._renderChildren ||
2354-
getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
2355-
)
2346+
getScopedSlotRenderFunctions(this)
2347+
.map(function (x) {
2348+
var result = null;
2349+
try {
2350+
result = this$1.$vnode.data.scopedSlots[x]({});
2351+
} catch (e) {}
2352+
return result
2353+
})
2354+
.filter(Boolean)
23562355
)
23572356
}})
23582357
}

Diff for: packages/test-utils/dist/vue-test-utils.umd.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -2302,16 +2302,8 @@
23022302
// In Vue 2.6+ a new v-slot syntax was introduced
23032303
// scopedSlots are now saved in parent._vnode.data.scopedSlots
23042304
// We filter out _normalized, $stable and $key keys
2305-
if (
2306-
ctx &&
2307-
ctx.$options &&
2308-
ctx.$options.parent &&
2309-
ctx.$options.parent._vnode &&
2310-
ctx.$options.parent._vnode.data &&
2311-
ctx.$options.parent._vnode.data.scopedSlots
2312-
) {
2313-
var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
2314-
return keys(slotKeys).filter(
2305+
if (ctx.$vnode.data.scopedSlots) {
2306+
return keys(ctx.$vnode.data.scopedSlots).filter(
23152307
function (x) { return x !== '_normalized' && x !== '$stable' && x !== '$key'; }
23162308
)
23172309
}
@@ -2350,8 +2342,15 @@
23502342
context
23512343
? context.children
23522344
: this.$options._renderChildren ||
2353-
getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x]({}); }
2354-
)
2345+
getScopedSlotRenderFunctions(this)
2346+
.map(function (x) {
2347+
var result = null;
2348+
try {
2349+
result = this$1.$vnode.data.scopedSlots[x]({});
2350+
} catch (e) {}
2351+
return result
2352+
})
2353+
.filter(Boolean)
23552354
)
23562355
}})
23572356
}

Diff for: packages/test-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/test-utils",
3-
"version": "1.3.5",
3+
"version": "1.3.6",
44
"description": "Utilities for testing Vue components.",
55
"main": "dist/vue-test-utils.js",
66
"module": "dist/vue-test-utils.esm.js",

Diff for: test/specs/shallow-mount.spec.js

+32
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,38 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
164164
)
165165
})
166166

167+
it('renders named slots with v-slot syntax when they are wrapped', () => {
168+
const localVue = createLocalVue()
169+
localVue.component('Foo', {
170+
template: '<div><slot name="newSyntax" /></div>'
171+
})
172+
const TestComponent = {
173+
template: `
174+
<div>
175+
<Foo>
176+
<template v-slot:newSyntax>
177+
<p class="new-example">text</p>
178+
</template>
179+
</Foo>
180+
</div>
181+
`
182+
}
183+
const wrapper = shallowMount(TestComponent, {
184+
localVue
185+
})
186+
expect(wrapper.find({ name: 'Foo' }).exists()).toEqual(true)
187+
expect(wrapper.find('.new-example').exists()).toEqual(true)
188+
expect(wrapper.html()).toEqual(
189+
[
190+
'<div>',
191+
' <foo-stub>',
192+
' <p class="new-example">text</p>',
193+
' </foo-stub>',
194+
'</div>'
195+
].join('\n')
196+
)
197+
})
198+
167199
it('renders named slots when they are located inside component with v-if', () => {
168200
const localVue = createLocalVue()
169201
localVue.component('Foo', {

0 commit comments

Comments
 (0)