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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 14018022: Fix model-tree-observer in html. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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:
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/src/ModelTreeObserver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index f62c4ac11af0ab242d4aef15f38fcd8a04290590..54a2cabf460c4b769c40a52da49f1801ac266939 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -18719,7 +18719,7 @@ class Node extends EventTarget {
@Experimental
get model {
// If we have a change handler then we've cached the model locally.
- if (!_modelChangedStreams.isEmpty) {
+ if (_modelChangedStreams != null && !_modelChangedStreams.isEmpty) {
return _model;
}
// Otherwise start looking up the tree.
@@ -18739,7 +18739,7 @@ class Node extends EventTarget {
_ModelTreeObserver.initialize();
if (changed) {
- if (!_modelChangedStreams.isEmpty) {
+ if (_modelChangedStreams != null && !_modelChangedStreams.isEmpty) {
_modelChangedStreams.toList().forEach((stream) => stream.add(this));
}
// Propagate new model to all descendants.
@@ -18769,11 +18769,14 @@ class Node extends EventTarget {
* Get a stream of models, whenever the model changes.
*/
Stream<Node> get onModelChanged {
- var result;
- result = new StreamController(
- onListen: () { _modelChangedStreams.add(result); },
- onCancel: () { _modelChangedStreams.remove(result); });
- return result;
+ if (_modelChangedStreams == null) {
+ _modelChangedStreams = new Set<StreamController<Node>>();
+ }
+ var controller;
+ controller = new StreamController(
+ onListen: () { _modelChangedStreams.add(controller); },
+ onCancel: () { _modelChangedStreams.remove(controller); });
+ return controller.stream;
}
/**
@@ -32852,9 +32855,11 @@ class _ModelTreeObserver {
// Catch and report them a global exceptions.
try {
if (node._hasLocalModel != true && node._model != model &&
- node._modelChangedStream != null) {
+ node._modelChangedStreams != null &&
+ !node._modelChangedStreams.isEmpty) {
node._model = model;
- node._modelChangedStream.add(node);
+ node._modelChangedStreams.toList()
+ .forEach((controller) => controller.add(node));
}
} catch (e, s) {
new Future.immediateError(e, s);
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/src/ModelTreeObserver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698