A RetroSearch Logo

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

Search Query:

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

add scopedSlots to context in functional components… · vuejs/vue@fb6aa06 · GitHub

File tree Expand file treeCollapse file tree 4 files changed

+21

-1

lines changed

Filter options

Expand file treeCollapse file tree 4 files changed

+21

-1

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

@@ -48,6 +48,7 @@ export function FunctionalRenderContext (

48 48

this.children = children

49 49

this.parent = parent

50 50

this.listeners = data.on || emptyObject

51 +

this.scopedSlots = data.scopedSlots || emptyObject

51 52

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

52 53

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

53 54 Original file line number Diff line number Diff line change

@@ -79,6 +79,23 @@ describe('Options functional', () => {

79 79

document.body.removeChild(vm.$el)

80 80

})

81 81 82 +

it('should expose data.scopedSlots as scopedSlots', () => {

83 +

const vm = new Vue({

84 +

template: '<div><wrap><p slot-scope="a">{{ a }}</p></wrap></div>',

85 +

components: {

86 +

wrap: {

87 +

functional: true,

88 +

render (h, { scopedSlots, data }) {

89 +

expect(data.scopedSlots).toBe(scopedSlots)

90 +

return data.scopedSlots.default('a')

91 +

}

92 +

}

93 +

}

94 +

}).$mount()

95 + 96 +

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

97 +

})

98 + 82 99

it('should support returning more than one root node', () => {

83 100

const vm = new Vue({

84 101

template: `<div><test></test></div>`,

Original file line number Diff line number Diff line change

@@ -1,5 +1,5 @@

1 1

import { Vue, CreateElement, CombinedVueInstance } from "./vue";

2 -

import { VNode, VNodeData, VNodeDirective } from "./vnode";

2 +

import { VNode, VNodeData, VNodeDirective, ScopedSlot } from "./vnode";

3 3 4 4

type Constructor = {

5 5

new (...args: any[]): any;

@@ -140,6 +140,7 @@ export interface RenderContext<Props=DefaultProps> {

140 140

data: VNodeData;

141 141

parent: Vue;

142 142

listeners: { [key: string]: Function | Function[] };

143 +

scopedSlots: { [key: string]: ScopedSlot };

143 144

injections: any

144 145

}

145 146 Original file line number Diff line number Diff line change

@@ -381,6 +381,7 @@ Vue.component('functional-component', {

381 381

context.slots();

382 382

context.data;

383 383

context.parent;

384 +

context.scopedSlots;

384 385

context.listeners.click;

385 386

return createElement("div", {}, context.children);

386 387

}

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