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

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

Issue 19771010: implement dirty checking for @observable objects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: logging for loops in dirty checking Created 7 years, 5 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 /** Extensions to the [Element] API. */ 7 /** Extensions to the [Element] API. */
8 class _ElementExtension extends _NodeExtension { 8 class _ElementExtension extends _NodeExtension {
9 _ElementExtension(Element node) : super(node); 9 _ElementExtension(Element node) : super(node);
10 10
(...skipping 25 matching lines...) Expand all
36 } else { 36 } else {
37 changed = (value) { 37 changed = (value) {
38 // TODO(jmesserly): escape value if needed to protect against XSS. 38 // TODO(jmesserly): escape value if needed to protect against XSS.
39 // See https://github.com/polymer-project/mdv/issues/58 39 // See https://github.com/polymer-project/mdv/issues/58
40 node.xtag.attributes[name] = value == null ? '' : '$value'; 40 node.xtag.attributes[name] = value == null ? '' : '$value';
41 }; 41 };
42 } 42 }
43 43
44 unbind(name); 44 unbind(name);
45 45
46 _attributeBindings[name] = 46 _attributeBindings[name] = new PathObserver(model, path).bindSync(changed);
47 new PathObserver(model, path).bindSync(changed);
48 } 47 }
49 48
50 void unbind(String name) { 49 void unbind(String name) {
51 if (_attributeBindings != null) { 50 if (_attributeBindings != null) {
52 var binding = _attributeBindings.remove(name); 51 var binding = _attributeBindings.remove(name);
53 if (binding != null) binding.cancel(); 52 if (binding != null) binding.cancel();
54 } 53 }
55 } 54 }
56 55
57 void unbindAll() { 56 void unbindAll() {
58 if (_attributeBindings != null) { 57 if (_attributeBindings != null) {
59 for (var binding in _attributeBindings.values) { 58 for (var binding in _attributeBindings.values) {
60 binding.cancel(); 59 binding.cancel();
61 } 60 }
62 _attributeBindings = null; 61 _attributeBindings = null;
63 } 62 }
64 } 63 }
65 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698