From 44e165a357050cdfd1a7a278fc3af44839cdf4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Yves=20G=C3=A9rardy?= Date: Mon, 23 Apr 2018 11:37:24 +0200 Subject: [PATCH] [render/render] Misc comment fixes --- render/render.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/render/render.js b/render/render.js index 54ed3cb2..b9b6411a 100644 --- a/render/render.js +++ b/render/render.js @@ -187,10 +187,8 @@ module.exports = function($window) { // // The updateNodes() function: // - deals with trivial cases - // - determines whether the lists are keyed or unkeyed - // (Currently we look for the first pair of non-null nodes and deem the lists unkeyed - // if both nodes are unkeyed. TODO (v2) We may later take advantage of the fact that - // mixed diff is not supported and settle on the keyedness of the first vnode we find) + // - determines whether the lists are keyed or unkeyed based on the first non-null node + // of each list. // - diffs them and patches the DOM if needed (that's the brunt of the code) // - manages the leftovers: after diffing, are there: // - old nodes left to remove? @@ -265,7 +263,7 @@ module.exports = function($window) { else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns) else if (vnodes == null) removeNodes(old, 0, old.length) else { - // default to keyed because, when either list isfull of null nodes, it has fewer branches + // default to keyed because, when either list is full of null nodes, it has fewer branches var start = 0, oldStart = 0, isOldKeyed = true, isKeyed = true for (; oldStart < old.length; oldStart++) { if (old[oldStart] != null) { @@ -288,9 +286,8 @@ module.exports = function($window) { // Don't index past the end of either list (causes deopts). var commonLength = old.length < vnodes.length ? old.length : vnodes.length // Rewind if necessary to the first non-null index on either side. - // We could also either create or remove nodes when start !== oldStart - // but that would be optimizing for sparse lists which are more rare - // than dense ones. + // We could alternatively either explicitly create or remove nodes when `start !== oldStart` + // but that would be optimizing for sparse lists which are more rare than dense ones. start = start < oldStart ? start : oldStart for (; start < commonLength; start++) { o = old[start] @@ -308,7 +305,7 @@ module.exports = function($window) { var oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v while (oldEnd >= oldStart && end >= start) { - // both top down + // both top-down o = old[oldStart] v = vnodes[start] if (o == null) oldStart++