Skip to content

Commit

Permalink
fix functional context resolving merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 5, 2017
1 parent 4e12b25 commit 7d3c883
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
14 changes: 1 addition & 13 deletions src/core/instance/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,7 @@ export function resolveInject (inject: any, vm: Component): ?Object {
let source = vm
while (source) {
if (source._provided && provideKey in source._provided) {
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
defineReactive(vm, key, source._provided[provideKey], () => {
warn(
`Avoid mutating an injected value directly since the changes will be ` +
`overwritten whenever the provided component re-renders. ` +
`injection being mutated: "${key}"`,
vm
)
})
} else {
defineReactive(vm, key, source._provided[provideKey])
}
result[key] = source._provided[provideKey]
break
}
source = source.$parent
Expand Down
1 change: 0 additions & 1 deletion src/core/vdom/create-component.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* @flow */

import VNode from './vnode'
import { resolveInject } from '../instance/inject'
import { resolveConstructorOptions } from '../instance/init'
import { createFunctionalComponent } from './create-functional-component'

Expand Down
8 changes: 5 additions & 3 deletions src/core/vdom/create-functional-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import VNode from './vnode'
import { createElement } from './create-element'
import { resolveInject } from '../instance/inject'
import { resolveSlots } from '../instance/render-helpers/resolve-slots'

import {
Expand Down Expand Up @@ -32,11 +33,12 @@ export function createFunctionalComponent (
const _context = Object.create(context)
const h = (a, b, c, d) => createElement(_context, a, b, c, d, true)
const vnode = Ctor.options.render.call(null, h, {
props,
listeners: data.on || {},
data,
parent: context,
props,
children,
parent: context,
listeners: data.on || {},
injections: resolveInject(Ctor.options.inject, context),
slots: () => resolveSlots(children, context)
})
if (vnode instanceof VNode) {
Expand Down

0 comments on commit 7d3c883

Please sign in to comment.