mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 03:57:36 +08:00
tweak
This commit is contained in:
parent
61a5249a0e
commit
af1f1d349f
@ -102,7 +102,7 @@ function genChildren (el, asThunk) {
|
||||
}
|
||||
const code = '[' + el.children.map(genNode).join(',') + ']'
|
||||
return asThunk
|
||||
? `_withContext(function(){return ${code}})`
|
||||
? `_renderWithContext(function(){return ${code}})`
|
||||
: code
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Watcher from '../observer/watcher'
|
||||
import { extend, query, resolveAsset, hasOwn, isArray, isObject } from '../util/index'
|
||||
import { createElement, patch, updateListeners } from '../vdom/index'
|
||||
import { createElement, patch, updateListeners, flatten } from '../vdom/index'
|
||||
import { callHook } from './lifecycle'
|
||||
import { getPropValue } from './state'
|
||||
|
||||
@ -48,13 +48,14 @@ export function renderMixin (Vue) {
|
||||
this.$options._renderChildren = children
|
||||
// update props and listeners
|
||||
if (parentData) {
|
||||
// if any prop has changed it would trigger and queue an update,
|
||||
// but if no props changed, nothing happens
|
||||
updateProps(this, parentData)
|
||||
updateEvents(this, parentData, oldParentData)
|
||||
}
|
||||
// for now, if the component has content it always updates
|
||||
// because we don't know whether the children have changed.
|
||||
// need to optimize in the future.
|
||||
if (children || diffParentData(parentData, oldParentData)) {
|
||||
// diff parent data (attrs on the placeholder) and queue update
|
||||
// if anything changed
|
||||
if (diffParentData(parentData, oldParentData)) {
|
||||
this.$forceUpdate()
|
||||
}
|
||||
}
|
||||
@ -64,11 +65,11 @@ export function renderMixin (Vue) {
|
||||
* This is used to wrap all children thunks in codegen.
|
||||
*/
|
||||
|
||||
Vue.prototype._withContext = function (fn) {
|
||||
Vue.prototype._renderWithContext = function (fn) {
|
||||
return () => {
|
||||
const prev = renderState.context
|
||||
renderState.context = this
|
||||
const children = fn()
|
||||
const children = flatten(fn())
|
||||
renderState.context = prev
|
||||
return children
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import createPatchFunction from './patch'
|
||||
import createElement from './create-element'
|
||||
import createElement, { flatten } from './create-element'
|
||||
import classes from './modules/class'
|
||||
import style from './modules/style'
|
||||
import props from './modules/props'
|
||||
@ -22,4 +22,4 @@ const patch = createPatchFunction([
|
||||
directives
|
||||
])
|
||||
|
||||
export { patch, createElement, updateListeners }
|
||||
export { patch, createElement, updateListeners, flatten }
|
||||
|
Loading…
Reference in New Issue
Block a user