| OLD | NEW |
| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 void unobserve() { | 378 void unobserve() { |
| 379 if (_sub == null) return; | 379 if (_sub == null) return; |
| 380 _sub.cancel(); | 380 _sub.cancel(); |
| 381 _sub = null; | 381 _sub = null; |
| 382 } | 382 } |
| 383 | 383 |
| 384 void close() { | 384 void close() { |
| 385 if (closed) return; | 385 if (closed) return; |
| 386 | 386 |
| 387 unobserve(); | 387 unobserve(); |
| 388 inputs.close(); |
| 388 terminators.clear(); | 389 terminators.clear(); |
| 389 inputs.dispose(); | |
| 390 closed = true; | 390 closed = true; |
| 391 } | 391 } |
| 392 | 392 |
| 393 static void _unbindAllRecursively(Node node) { | 393 static void _unbindAllRecursively(Node node) { |
| 394 var nodeExt = _mdv(node); | 394 var nodeExt = _mdv(node); |
| 395 nodeExt._templateInstance = null; | 395 nodeExt._templateInstance = null; |
| 396 if (node is Element && (node as Element).isTemplate) { | 396 if (node is Element && (node as Element).isTemplate) { |
| 397 // Make sure we stop observing when we remove an element. | 397 // Make sure we stop observing when we remove an element. |
| 398 var templateIterator = nodeExt._templateIterator; | 398 var templateIterator = nodeExt._templateIterator; |
| 399 if (templateIterator != null) { | 399 if (templateIterator != null) { |
| 400 templateIterator.close(); | 400 templateIterator.close(); |
| 401 nodeExt._templateIterator = null; | 401 nodeExt._templateIterator = null; |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 | 404 |
| 405 _nodeOrCustom(node).unbindAll(); | 405 _nodeOrCustom(node).unbindAll(); |
| 406 for (var c = node.firstChild; c != null; c = c.nextNode) { | 406 for (var c = node.firstChild; c != null; c = c.nextNode) { |
| 407 _unbindAllRecursively(c); | 407 _unbindAllRecursively(c); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 } | 410 } |
| OLD | NEW |