Skip to content

Commit faecdb6

Browse files
committed
[build] 2.0.0-rc.5
1 parent 1c4ca4b commit faecdb6

File tree

8 files changed

+324
-222
lines changed

8 files changed

+324
-222
lines changed

dist/vue.common.js

+114-57
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,8 @@ function cloneVNodes (vnodes) {
14341434

14351435
function normalizeChildren (
14361436
children,
1437-
ns
1437+
ns,
1438+
nestedIndex
14381439
) {
14391440
if (isPrimitive(children)) {
14401441
return [createTextVNode(children)]
@@ -1446,7 +1447,7 @@ function normalizeChildren (
14461447
var last = res[res.length - 1]
14471448
// nested
14481449
if (Array.isArray(c)) {
1449-
res.push.apply(res, normalizeChildren(c, ns))
1450+
res.push.apply(res, normalizeChildren(c, ns, i))
14501451
} else if (isPrimitive(c)) {
14511452
if (last && last.text) {
14521453
last.text += String(c)
@@ -1462,6 +1463,10 @@ function normalizeChildren (
14621463
if (ns) {
14631464
applyNS(c, ns)
14641465
}
1466+
// default key for nested array children (likely generated by v-for)
1467+
if (c.key == null && nestedIndex != null) {
1468+
c.key = "__vlist_" + nestedIndex + "_" + i + "__"
1469+
}
14651470
res.push(c)
14661471
}
14671472
}
@@ -1533,13 +1538,15 @@ function updateListeners (
15331538
}
15341539
add(event, cur.invoker, capture)
15351540
}
1536-
} else if (Array.isArray(old)) {
1537-
old.length = cur.length
1538-
for (var i = 0; i < old.length; i++) old[i] = cur[i]
1539-
on[name] = old
1540-
} else {
1541-
old.fn = cur
1542-
on[name] = old
1541+
} else if (cur !== old) {
1542+
if (Array.isArray(old)) {
1543+
old.length = cur.length
1544+
for (var i = 0; i < old.length; i++) old[i] = cur[i]
1545+
on[name] = old
1546+
} else {
1547+
old.fn = cur
1548+
on[name] = old
1549+
}
15431550
}
15441551
}
15451552
for (name in oldOn) {
@@ -2142,13 +2149,6 @@ function renderMixin (Vue) {
21422149
var staticRenderFns = ref.staticRenderFns;
21432150
var _parentVnode = ref._parentVnode;
21442151

2145-
if (vm._isMounted) {
2146-
// clone slot nodes on re-renders
2147-
for (var key in vm.$slots) {
2148-
vm.$slots[key] = cloneVNodes(vm.$slots[key])
2149-
}
2150-
}
2151-
21522152
if (staticRenderFns && !vm._staticTrees) {
21532153
vm._staticTrees = []
21542154
}
@@ -2261,6 +2261,30 @@ function renderMixin (Vue) {
22612261
return ret
22622262
}
22632263

2264+
// renderSlot
2265+
Vue.prototype._t = function (
2266+
name,
2267+
fallback
2268+
) {
2269+
var slotNodes = this.$slots[name]
2270+
if (slotNodes) {
2271+
// warn duplicate slot usage
2272+
if (process.env.NODE_ENV !== 'production') {
2273+
slotNodes._rendered && warn(
2274+
"Duplicate presense of slot \"" + name + "\" found in the same render tree " +
2275+
"- this will likely cause render errors.",
2276+
this
2277+
)
2278+
slotNodes._rendered = true
2279+
}
2280+
// clone slot nodes on re-renders
2281+
if (this._isMounted) {
2282+
slotNodes = cloneVNodes(slotNodes)
2283+
}
2284+
}
2285+
return slotNodes || fallback
2286+
}
2287+
22642288
// apply v-bind object
22652289
Vue.prototype._b = function bindProps (
22662290
vnode,
@@ -3261,7 +3285,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
32613285
get: function () { return config._isServer; }
32623286
})
32633287

3264-
Vue.version = '2.0.0-rc.4'
3288+
Vue.version = '2.0.0-rc.5'
32653289

32663290
/* */
32673291

@@ -3704,7 +3728,7 @@ function createPatchFunction (backend) {
37043728
}
37053729

37063730
function createElm (vnode, insertedVnodeQueue, nested) {
3707-
var i, elm
3731+
var i
37083732
var data = vnode.data
37093733
vnode.isRootInsert = !nested
37103734
if (isDef(data)) {
@@ -3735,28 +3759,32 @@ function createPatchFunction (backend) {
37353759
)
37363760
}
37373761
}
3738-
elm = vnode.elm = vnode.ns
3762+
vnode.elm = vnode.ns
37393763
? nodeOps.createElementNS(vnode.ns, tag)
37403764
: nodeOps.createElement(tag)
37413765
setScope(vnode)
3742-
if (Array.isArray(children)) {
3743-
for (i = 0; i < children.length; ++i) {
3744-
nodeOps.appendChild(elm, createElm(children[i], insertedVnodeQueue, true))
3745-
}
3746-
} else if (isPrimitive(vnode.text)) {
3747-
nodeOps.appendChild(elm, nodeOps.createTextNode(vnode.text))
3748-
}
3766+
createChildren(vnode, children, insertedVnodeQueue)
37493767
if (isDef(data)) {
37503768
invokeCreateHooks(vnode, insertedVnodeQueue)
37513769
}
37523770
} else if (vnode.isComment) {
3753-
elm = vnode.elm = nodeOps.createComment(vnode.text)
3771+
vnode.elm = nodeOps.createComment(vnode.text)
37543772
} else {
3755-
elm = vnode.elm = nodeOps.createTextNode(vnode.text)
3773+
vnode.elm = nodeOps.createTextNode(vnode.text)
37563774
}
37573775
return vnode.elm
37583776
}
37593777

3778+
function createChildren (vnode, children, insertedVnodeQueue) {
3779+
if (Array.isArray(children)) {
3780+
for (var i = 0; i < children.length; ++i) {
3781+
nodeOps.appendChild(vnode.elm, createElm(children[i], insertedVnodeQueue, true))
3782+
}
3783+
} else if (isPrimitive(vnode.text)) {
3784+
nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text))
3785+
}
3786+
}
3787+
37603788
function isPatchable (vnode) {
37613789
while (vnode.child) {
37623790
vnode = vnode.child._vnode
@@ -3954,7 +3982,7 @@ function createPatchFunction (backend) {
39543982
// reuse element for static trees.
39553983
// note we only do this if the vnode is cloned -
39563984
// if the new node is not cloned it means the render functions have been
3957-
// reset by the hot-reload-api and we need to a proper re-render.
3985+
// reset by the hot-reload-api and we need to do a proper re-render.
39583986
if (vnode.isStatic &&
39593987
oldVnode.isStatic &&
39603988
vnode.key === oldVnode.key &&
@@ -4028,26 +4056,31 @@ function createPatchFunction (backend) {
40284056
if (isDef(tag)) {
40294057
if (isDef(children)) {
40304058
var childNodes = nodeOps.childNodes(elm)
4031-
var childrenMatch = true
4032-
if (childNodes.length !== children.length) {
4033-
childrenMatch = false
4059+
// empty element, allow client to pick up and populate children
4060+
if (!childNodes.length) {
4061+
createChildren(vnode, children, insertedVnodeQueue)
40344062
} else {
4035-
for (var i$1 = 0; i$1 < children.length; i$1++) {
4036-
if (!hydrate(childNodes[i$1], children[i$1], insertedVnodeQueue)) {
4037-
childrenMatch = false
4038-
break
4063+
var childrenMatch = true
4064+
if (childNodes.length !== children.length) {
4065+
childrenMatch = false
4066+
} else {
4067+
for (var i$1 = 0; i$1 < children.length; i$1++) {
4068+
if (!hydrate(childNodes[i$1], children[i$1], insertedVnodeQueue)) {
4069+
childrenMatch = false
4070+
break
4071+
}
40394072
}
40404073
}
4041-
}
4042-
if (!childrenMatch) {
4043-
if (process.env.NODE_ENV !== 'production' &&
4044-
typeof console !== 'undefined' &&
4045-
!bailed) {
4046-
bailed = true
4047-
console.warn('Parent: ', elm)
4048-
console.warn('Mismatching childNodes vs. VNodes: ', childNodes, children)
4074+
if (!childrenMatch) {
4075+
if (process.env.NODE_ENV !== 'production' &&
4076+
typeof console !== 'undefined' &&
4077+
!bailed) {
4078+
bailed = true
4079+
console.warn('Parent: ', elm)
4080+
console.warn('Mismatching childNodes vs. VNodes: ', childNodes, children)
4081+
}
4082+
return false
40494083
}
4050-
return false
40514084
}
40524085
}
40534086
if (isDef(data)) {
@@ -4142,9 +4175,18 @@ function createPatchFunction (backend) {
41424175

41434176
var directives = {
41444177
create: function bindDirectives (oldVnode, vnode) {
4145-
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
4146-
applyDirectives(oldVnode, vnode, 'bind')
4178+
var hasInsert = false
4179+
forEachDirective(oldVnode, vnode, function (def, dir) {
4180+
callHook$1(def, dir, 'bind', vnode, oldVnode)
4181+
if (def.inserted) {
4182+
hasInsert = true
4183+
}
41474184
})
4185+
if (hasInsert) {
4186+
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
4187+
applyDirectives(oldVnode, vnode, 'inserted')
4188+
})
4189+
}
41484190
},
41494191
update: function updateDirectives (oldVnode, vnode) {
41504192
applyDirectives(oldVnode, vnode, 'update')
@@ -4164,32 +4206,47 @@ var directives = {
41644206

41654207
var emptyModifiers = Object.create(null)
41664208

4167-
function applyDirectives (
4209+
function forEachDirective (
41684210
oldVnode,
41694211
vnode,
4170-
hook
4212+
fn
41714213
) {
41724214
var dirs = vnode.data.directives
41734215
if (dirs) {
4174-
var oldDirs = oldVnode.data.directives
4175-
var isUpdate = hook === 'update' || hook === 'componentUpdated'
41764216
for (var i = 0; i < dirs.length; i++) {
41774217
var dir = dirs[i]
41784218
var def = resolveAsset(vnode.context.$options, 'directives', dir.name, true)
4179-
var fn = def && def[hook]
4180-
if (fn) {
4181-
if (isUpdate && oldDirs) {
4219+
if (def) {
4220+
var oldDirs = oldVnode && oldVnode.data.directives
4221+
if (oldDirs) {
41824222
dir.oldValue = oldDirs[i].value
41834223
}
41844224
if (!dir.modifiers) {
41854225
dir.modifiers = emptyModifiers
41864226
}
4187-
fn(vnode.elm, dir, vnode, oldVnode)
4227+
fn(def, dir)
41884228
}
41894229
}
41904230
}
41914231
}
41924232

4233+
function applyDirectives (
4234+
oldVnode,
4235+
vnode,
4236+
hook
4237+
) {
4238+
forEachDirective(oldVnode, vnode, function (def, dir) {
4239+
callHook$1(def, dir, hook, vnode, oldVnode)
4240+
})
4241+
}
4242+
4243+
function callHook$1 (def, dir, hook, vnode, oldVnode) {
4244+
var fn = def && def[hook]
4245+
if (fn) {
4246+
fn(vnode.elm, dir, vnode, oldVnode)
4247+
}
4248+
}
4249+
41934250
var baseModules = [
41944251
ref,
41954252
directives
@@ -5019,7 +5076,7 @@ var show = {
50195076

50205077
vnode = locateNode(vnode)
50215078
var transition = vnode.data && vnode.data.transition
5022-
if (value && transition && transition.appear && !isIE9) {
5079+
if (value && transition && !isIE9) {
50235080
enter(vnode)
50245081
}
50255082
var originalDisplay = el.style.display === 'none' ? '' : el.style.display
@@ -5249,7 +5306,7 @@ var TransitionGroup = {
52495306
for (var i = 0; i < rawChildren.length; i++) {
52505307
var c = rawChildren[i]
52515308
if (c.tag) {
5252-
if (c.key != null) {
5309+
if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
52535310
children.push(c)
52545311
map[c.key] = c
52555312
;(c.data || (c.data = {})).transition = transitionData

0 commit comments

Comments
 (0)