[render/render] get rid of vnode.skip
This commit is contained in:
parent
e3b240032a
commit
144ce68192
2 changed files with 6 additions and 9 deletions
|
|
@ -221,13 +221,13 @@ module.exports = function($window) {
|
||||||
// The fourth section does keyed diff for the situations not covered by the other three. It
|
// The fourth section does keyed diff for the situations not covered by the other three. It
|
||||||
// builds a {key: oldIndex} dictionary and uses it to find old nodes that match the keys of
|
// builds a {key: oldIndex} dictionary and uses it to find old nodes that match the keys of
|
||||||
// new ones.
|
// new ones.
|
||||||
// The nodes from the `old` array that have a match in the new `vnodes` one are marked as
|
// The nodes from the `old` array that have a match in the new `vnodes` one are removed from
|
||||||
// `vnode.skip: true`.
|
// the old list (set to `null`).
|
||||||
//
|
//
|
||||||
// If there are still nodes in the new `vnodes` array that haven't been matched to old ones,
|
// If there are still nodes in the new `vnodes` array that haven't been matched to old ones,
|
||||||
// they are created.
|
// they are created.
|
||||||
// The range of old nodes that wasn't covered by the first three sections is passed to
|
// The range of old nodes that wasn't covered by the first three sections is passed to
|
||||||
// `removeNodes()`. Those nodes are removed unless marked as `.skip: true`.
|
// `removeNodes()`. The nodes that remain in the list are removed from the DOM.
|
||||||
//
|
//
|
||||||
// It should be noted that the description of the four sections above is not perfect, because those
|
// It should be noted that the description of the four sections above is not perfect, because those
|
||||||
// parts are actually implemented as only two loops, one for the first two parts, and one for
|
// parts are actually implemented as only two loops, one for the first two parts, and one for
|
||||||
|
|
@ -380,7 +380,7 @@ module.exports = function($window) {
|
||||||
pos = (oldIndex < pos) ? oldIndex : -1 // becomes -1 if nodes were re-ordered
|
pos = (oldIndex < pos) ? oldIndex : -1 // becomes -1 if nodes were re-ordered
|
||||||
oldIndices[i-start] = oldIndex
|
oldIndices[i-start] = oldIndex
|
||||||
o = old[oldIndex]
|
o = old[oldIndex]
|
||||||
o.skip = true
|
old[oldIndex] = null
|
||||||
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||||
if (v.dom != null) nextSibling = v.dom
|
if (v.dom != null) nextSibling = v.dom
|
||||||
matched = true
|
matched = true
|
||||||
|
|
@ -605,10 +605,7 @@ module.exports = function($window) {
|
||||||
function removeNodes(vnodes, start, end) {
|
function removeNodes(vnodes, start, end) {
|
||||||
for (var i = start; i < end; i++) {
|
for (var i = start; i < end; i++) {
|
||||||
var vnode = vnodes[i]
|
var vnode = vnodes[i]
|
||||||
if (vnode != null) {
|
if (vnode != null) removeNode(vnode)
|
||||||
if (vnode.skip) vnode.skip = false
|
|
||||||
else removeNode(vnode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function removeNode(vnode) {
|
function removeNode(vnode) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
function Vnode(tag, key, attrs, children, text, dom) {
|
function Vnode(tag, key, attrs, children, text, dom) {
|
||||||
return {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined, skip: false}
|
return {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}
|
||||||
}
|
}
|
||||||
Vnode.normalize = function(node) {
|
Vnode.normalize = function(node) {
|
||||||
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
|
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue