A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue/commit/6dd73e9ee44c09f04d3f616fcce18750a55e2e4f below:

named slots for nested functional components · vuejs/vue@6dd73e9 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+47

-6

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+47

-6

lines changed Original file line number Diff line number Diff line change

@@ -10,6 +10,7 @@ import { installRenderHelpers } from '../instance/render-helpers/index'

10 10

import {

11 11

isDef,

12 12

isTrue,

13 +

hasOwn,

13 14

camelize,

14 15

emptyObject,

15 16

validateProp

@@ -23,6 +24,21 @@ export function FunctionalRenderContext (

23 24

Ctor: Class<Component>

24 25

) {

25 26

const options = Ctor.options

27 +

// ensure the createElement function in functional components

28 +

// gets a unique context - this is necessary for correct named slot check

29 +

let contextVm

30 +

if (hasOwn(parent, '_uid')) {

31 +

contextVm = Object.create(parent)

32 +

// $flow-disable-line

33 +

contextVm._original = parent

34 +

} else {

35 +

contextVm = parent

36 +

// $flow-disable-line

37 +

parent = parent._original

38 +

}

39 +

const isCompiled = isTrue(options._compiled)

40 +

const needNormalization = !isCompiled

41 + 26 42

this.data = data

27 43

this.props = props

28 44

this.children = children

@@ -31,12 +47,6 @@ export function FunctionalRenderContext (

31 47

this.injections = resolveInject(options.inject, parent)

32 48

this.slots = () => resolveSlots(children, parent)

33 49 34 -

// ensure the createElement function in functional components

35 -

// gets a unique context - this is necessary for correct named slot check

36 -

const contextVm = Object.create(parent)

37 -

const isCompiled = isTrue(options._compiled)

38 -

const needNormalization = !isCompiled

39 - 40 50

// support for compiled functional template

41 51

if (isCompiled) {

42 52

// exposing $options for renderStatic()

Original file line number Diff line number Diff line change

@@ -824,4 +824,35 @@ describe('Component slot', () => {

824 824

expect(vm.$el.textContent).toBe('hello')

825 825

}).then(done)

826 826

})

827 + 828 +

it('should allow passing named slots as raw children down multiple layers of functional component', () => {

829 +

const CompB = {

830 +

functional: true,

831 +

render (h, { slots }) {

832 +

return slots().foo

833 +

}

834 +

}

835 + 836 +

const CompA = {

837 +

functional: true,

838 +

render (h, { children }) {

839 +

return h(CompB, children)

840 +

}

841 +

}

842 + 843 +

const vm = new Vue({

844 +

components: {

845 +

CompA

846 +

},

847 +

template: `

848 +

<div>

849 +

<comp-a>

850 +

<span slot="foo">foo</span>

851 +

</comp-a>

852 +

</div>

853 +

`

854 +

}).$mount()

855 + 856 +

expect(vm.$el.textContent).toBe('foo')

857 +

})

827 858

})

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4