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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.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 | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index c845b333dcfb9b57fac592062886fac3f4f61242..ffe98ae8a3bbb1c050d9770bf64c128cc2db6c93 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -17373,7 +17373,7 @@ class Node extends EventTarget native "*Node" {
@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.
@@ -17393,7 +17393,7 @@ class Node extends EventTarget native "*Node" {
_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.
@@ -17423,11 +17423,14 @@ class Node extends EventTarget native "*Node" {
* 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;
}
/**
@@ -30663,9 +30666,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 | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698