This commit is contained in:
Dan
2019-04-19 13:17:17 +01:00
parent 3e657a6031
commit efb5855c8c
2 changed files with 10 additions and 23 deletions
+8 -4
View File
@@ -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
View File
@@ -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: