Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Unified Diff: sky/sdk/lib/framework/fn2.dart

Issue 1158563003: [Effen] Make syncChild() support the _new_ child being null. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/fn2.dart
diff --git a/sky/sdk/lib/framework/fn2.dart b/sky/sdk/lib/framework/fn2.dart
index 4c9bf6eeb67aea018d3d70dfc5fe6afb61e4a521..4f8318b39ad32d5569bb14c59a88f21e4e457427 100644
--- a/sky/sdk/lib/framework/fn2.dart
+++ b/sky/sdk/lib/framework/fn2.dart
@@ -93,15 +93,20 @@ abstract class UINode {
}
// Returns the child which should be retained as the child of this node.
- UINode _syncChild(UINode node, UINode oldNode, dynamic slot) {
- assert(node != null);
- assert(oldNode == null || node._key == oldNode._key);
+ UINode syncChild(UINode node, UINode oldNode, dynamic slot) {
if (node == oldNode) {
- _traceSync(_SyncOperation.IDENTICAL, node._key);
+ _traceSync(_SyncOperation.IDENTICAL, node == null ? '*null*' : node._key);
return node; // Nothing to do. Subtrees must be identical.
}
+ if (node == null) {
+ // the child in this slot has gone away
+ removeChild(oldNode);
+ return null;
+ }
+ assert(oldNode == null || node._key == oldNode._key);
+
// TODO(rafaelw): This eagerly removes the old DOM. It may be that a
// new component was built that could re-use some of it. Consider
// syncing the new VDOM against the old one.
@@ -141,7 +146,7 @@ abstract class ContentNode extends UINode {
void _sync(UINode old, dynamic slot) {
UINode oldContent = old == null ? null : (old as ContentNode).content;
- content = _syncChild(content, oldContent, slot);
+ content = syncChild(content, oldContent, slot);
assert(content.root != null);
root = content.root;
}
@@ -441,7 +446,7 @@ abstract class OneChildListRenderNodeWrapper extends RenderNodeWrapper {
UINode oldNode = null;
void sync(int atIndex) {
- children[atIndex] = _syncChild(currentNode, oldNode, nextSibling);
+ children[atIndex] = syncChild(currentNode, oldNode, nextSibling);
assert(children[atIndex] != null);
}
@@ -899,7 +904,7 @@ abstract class Component extends UINode {
_currentlyBuilding = null;
_currentOrder = lastOrder;
- _built = _syncChild(_built, oldBuilt, slot);
+ _built = syncChild(_built, oldBuilt, slot);
_dirty = false;
root = _built.root;
assert(root != null);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698