mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Nits
This commit is contained in:
+8
-4
@@ -69,16 +69,20 @@ For example, adding a function component `<Foo>` with an id 2:
|
||||
|
||||
#### Removing a node
|
||||
|
||||
Removing a fiber from the tree (a root or a leaf) only requires sending 2 numbers:
|
||||
Removing a fiber from the tree (a root or a leaf) requires sending:
|
||||
|
||||
1. remove operation constant (`2`)
|
||||
1. fiber id
|
||||
1. how many items were removed
|
||||
1. number of children
|
||||
* (followed by a children-first list of removed fiber ids)
|
||||
|
||||
For example, removing a root fiber with an id of 1:
|
||||
For example, removing fibers with ids of 35 and 21:
|
||||
```js
|
||||
[
|
||||
2, // remove operation
|
||||
1, // fiber id
|
||||
1, // number of removed fibers
|
||||
35, // first removed id
|
||||
21, // second removed id
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
+2
-19
@@ -601,8 +601,8 @@ export default class Store extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
let addedElementIDs: Array<number> = [];
|
||||
let removedElementIDs: Array<number> = [];
|
||||
const addedElementIDs: Array<number> = [];
|
||||
const removedElementIDs: Array<number> = [];
|
||||
|
||||
let i = 2;
|
||||
while (i < operations.length) {
|
||||
@@ -811,23 +811,6 @@ export default class Store extends EventEmitter {
|
||||
}
|
||||
}
|
||||
element.children = Array.from(nextChildren);
|
||||
|
||||
if (!element.isCollapsed) {
|
||||
const prevWeight = element.weight;
|
||||
|
||||
let nextWeight = element.type === ElementTypeRoot ? 0 : 1;
|
||||
|
||||
nextChildren.forEach(childID => {
|
||||
const child = ((this._idToElement.get(childID): any): Element);
|
||||
nextWeight += child.isCollapsed ? 1 : child.weight;
|
||||
});
|
||||
|
||||
element.weight = nextWeight;
|
||||
// TODO: passing null here is suspicious, but it's existing behavior.
|
||||
// It is suspicious because either we shouldn't need a delta at all--
|
||||
// or we should apply it to all parents, and not just this item.
|
||||
this._adjustParentTreeWeight(null, nextWeight - prevWeight);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TREE_OPERATION_UPDATE_TREE_BASE_DURATION:
|
||||
|
||||
Reference in New Issue
Block a user