Skip to content

Commit 7630622

Browse files
committed
expose component placeholder node in render fns as this.$vnode
1 parent 7b4400d commit 7630622

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

flow/component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ declare interface Component {
2626
$children: Array<Component>;
2727
$refs: { [key: string]: Component | Element | Array<Component | Element> | void };
2828
$slots: { [key: string]: Array<VNode> };
29+
$vnode: VNode;
2930
$isServer: boolean;
3031

3132
// public methods

src/core/instance/render.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export const renderState: {
1717
}
1818

1919
export function initRender (vm: Component) {
20-
vm._vnode = null
20+
vm.$vnode = null // the placeholder node in parent tree
21+
vm._vnode = null // the root of the child tree
2122
vm._staticTrees = null
2223
vm.$slots = {}
2324
// bind the public createElement fn to this instance
@@ -50,7 +51,9 @@ export function renderMixin (Vue: Class<Component>) {
5051
if (staticRenderFns && !this._staticTrees) {
5152
this._staticTrees = []
5253
}
53-
54+
// set parent vnode. this allows render functions to have access
55+
// to the data on the placeholder node.
56+
this.$vnode = _parentVnode
5457
// resolve slots. becaues slots are rendered in parent scope,
5558
// we set the activeInstance to parent.
5659
if (_renderChildren) {

0 commit comments

Comments
 (0)