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

Side by Side Diff: pkg/mdv/lib/src/template_iterator.dart

Issue 23494027: Make LinkedHashMap also have a factory constructor and be customizable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of mdv; 5 part of mdv;
6 6
7 // This code is a port of Model-Driven-Views: 7 // This code is a port of Model-Driven-Views:
8 // https://github.com/polymer-project/mdv 8 // https://github.com/polymer-project/mdv
9 // The code mostly comes from src/template_element.js 9 // The code mostly comes from src/template_element.js
10 10
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 var delegate = template.bindingDelegate; 337 var delegate = template.bindingDelegate;
338 338
339 if (template.parentNode == null || template.document.window == null) { 339 if (template.parentNode == null || template.document.window == null) {
340 close(); 340 close();
341 // TODO(jmesserly): MDV calls templateIteratorTable.delete(this) here, 341 // TODO(jmesserly): MDV calls templateIteratorTable.delete(this) here,
342 // but I think that's a no-op because only nodes are used as keys. 342 // but I think that's a no-op because only nodes are used as keys.
343 // See https://github.com/Polymer/mdv/pull/114. 343 // See https://github.com/Polymer/mdv/pull/114.
344 return; 344 return;
345 } 345 }
346 346
347 // TODO(jmesserly): IdentityMap matches JS semantics, but it's O(N) right 347 var instanceCache = new HashMap(equals: identical);
348 // now. See http://dartbug.com/4161.
349 var instanceCache = new IdentityMap();
350 var removeDelta = 0; 348 var removeDelta = 0;
351 for (var splice in splices) { 349 for (var splice in splices) {
352 for (int i = 0; i < splice.removedCount; i++) { 350 for (int i = 0; i < splice.removedCount; i++) {
353 var instanceNodes = extractInstanceAt(splice.index + removeDelta); 351 var instanceNodes = extractInstanceAt(splice.index + removeDelta);
354 if (instanceNodes.length == 0) continue; 352 if (instanceNodes.length == 0) continue;
355 var model = _mdv(instanceNodes.first)._templateInstance.model; 353 var model = _mdv(instanceNodes.first)._templateInstance.model;
356 instanceCache[model] = instanceNodes; 354 instanceCache[model] = instanceNodes;
357 } 355 }
358 356
359 removeDelta -= splice.addedCount; 357 removeDelta -= splice.addedCount;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 nodeExt._templateIterator = null; 405 nodeExt._templateIterator = null;
408 } 406 }
409 } 407 }
410 408
411 _nodeOrCustom(node).unbindAll(); 409 _nodeOrCustom(node).unbindAll();
412 for (var c = node.firstChild; c != null; c = c.nextNode) { 410 for (var c = node.firstChild; c != null; c = c.nextNode) {
413 _unbindAllRecursively(c); 411 _unbindAllRecursively(c);
414 } 412 }
415 } 413 }
416 } 414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698