From e4f9d626da67839e4763f4f7661d31ad0c037d0d Mon Sep 17 00:00:00 2001 From: Tran Tu Date: Tue, 8 May 2018 23:18:02 -0700 Subject: [PATCH] fix: add _compiled to functional so that it handles slot properly --- lib/process.js | 1 + test/FunctionalSFC.spec.js | 11 +++++++++++ test/resources/FunctionalSFC.vue | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/process.js b/lib/process.js index c5b2fab4..d677fd41 100644 --- a/lib/process.js +++ b/lib/process.js @@ -69,6 +69,7 @@ module.exports = function (src, filePath, jestConfig) { if (parts.template.attrs.functional) { output += '__vue__options__.functional = true\n' + output += '__vue__options__._compiled = true\n' } if (map) { diff --git a/test/FunctionalSFC.spec.js b/test/FunctionalSFC.spec.js index 7e6bd05c..5f3f21c1 100644 --- a/test/FunctionalSFC.spec.js +++ b/test/FunctionalSFC.spec.js @@ -25,4 +25,15 @@ describe('Processes .vue file with functional template', () => { // note: for new version of @vue/vue-utils we can use wrapper.isFunctionalComponent for this expect(wrapper.vm._vnode.fnOptions.functional).toBe(true) }) + + it('handles slot', () => { + wrapper = shallow(FunctionalSFC, { + context: { + props: { msg: { id: 1, title: '' }}, + children: ['this is a slot'] + } + }) + + expect(wrapper.text()).toBe('this is a slot') + }) }) diff --git a/test/resources/FunctionalSFC.vue b/test/resources/FunctionalSFC.vue index 696dfe20..6f3922ed 100644 --- a/test/resources/FunctionalSFC.vue +++ b/test/resources/FunctionalSFC.vue @@ -1,3 +1,6 @@