Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
var => const/let
So that I can add a block scoped variable.
  • Loading branch information
gaearon committed Oct 9, 2017
commit 2e099be61b72434c7c28109d78048cbd4972b926
8 changes: 4 additions & 4 deletions src/renderers/shared/shared/ReactTreeTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function traverseTwoPhase(inst, fn, arg) {
* "entered" or "left" that element.
*/
function traverseEnterLeave(from, to, fn, argFrom, argTo) {
var common = from && to ? getLowestCommonAncestor(from, to) : null;
var pathFrom = [];
const common = from && to ? getLowestCommonAncestor(from, to) : null;
const pathFrom = [];
while (true) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to avoid while (true) since (at least in older versions) it has been known to deopt.

I appreciate the rewrite for the temp variable and easy of read. But arguably this just make the condition seem a lot more complicated than it really is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't it deopt when you have continues rather than break? I don't remember. @trueadm

if (!from) {
break;
Expand All @@ -122,7 +122,7 @@ function traverseEnterLeave(from, to, fn, argFrom, argTo) {
pathFrom.push(from);
from = getParent(from);
}
var pathTo = [];
const pathTo = [];
while (true) {
if (!to) {
break;
Expand All @@ -133,7 +133,7 @@ function traverseEnterLeave(from, to, fn, argFrom, argTo) {
pathTo.push(to);
to = getParent(to);
}
var i;
let i;
for (i = 0; i < pathFrom.length; i++) {
fn(pathFrom[i], 'bubbled', argFrom);
}
Expand Down