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 // TODO(jmesserly): can we handle this more elegantly? | 5 // TODO(jmesserly): can we handle this more elegantly? |
6 // In general, it seems like we want a convenient way to take a Stream plus a | 6 // In general, it seems like we want a convenient way to take a Stream plus a |
7 // getter and convert this into an Observable. | 7 // getter and convert this into an Observable. |
8 | 8 |
9 /** Helpers for exposing dart:html as observable data. */ | 9 /** Helpers for exposing dart:html as observable data. */ |
10 library observe.html; | 10 library observe.html; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 _notifyHashChange(null); | 44 _notifyHashChange(null); |
45 } | 45 } |
46 | 46 |
47 void _notifyHashChange(_) { | 47 void _notifyHashChange(_) { |
48 var oldValue = _currentHash; | 48 var oldValue = _currentHash; |
49 _currentHash = hash; | 49 _currentHash = hash; |
50 notifyPropertyChange(#hash, oldValue, _currentHash); | 50 notifyPropertyChange(#hash, oldValue, _currentHash); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 /** Add or remove CSS class [className] based on the [value]. */ | 54 /** |
| 55 * *Deprecated* use [CssClassSet.toggle] instead. |
| 56 * |
| 57 * Add or remove CSS class [className] based on the [value]. |
| 58 */ |
| 59 @deprecated |
55 void updateCssClass(Element element, String className, bool value) { | 60 void updateCssClass(Element element, String className, bool value) { |
56 if (value == true) { | 61 if (value == true) { |
57 element.classes.add(className); | 62 element.classes.add(className); |
58 } else { | 63 } else { |
59 element.classes.remove(className); | 64 element.classes.remove(className); |
60 } | 65 } |
61 } | 66 } |
62 | 67 |
63 /** Bind a CSS class to the observable [object] and property [path]. */ | 68 /** |
| 69 * *Deprecated* use `class="{{ binding }}"` in your HTML instead. It will also |
| 70 * work on a `<polymer-element>`. |
| 71 * |
| 72 * Bind a CSS class to the observable [object] and property [path]. |
| 73 */ |
| 74 @deprecated |
64 PathObserver bindCssClass(Element element, String className, | 75 PathObserver bindCssClass(Element element, String className, |
65 Observable object, String path) { | 76 Observable object, String path) { |
66 | 77 |
67 return new PathObserver(object, path)..bindSync((value) { | 78 callback(value) { |
68 updateCssClass(element, className, value); | 79 updateCssClass(element, className, value); |
69 }); | 80 } |
| 81 |
| 82 var obs = new PathObserver(object, path); |
| 83 callback(obs.open(callback)); |
| 84 return obs; |
70 } | 85 } |
OLD | NEW |