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 dart.dom.html; | 5 part of dart.dom.html; |
6 | 6 |
7 _wrapZone(callback(arg)) { | 7 // TODO(jacobr): remove these typedefs when dart:async supports generic types. |
| 8 typedef R _wrapZoneCallback<A, R>(A a); |
| 9 typedef R _wrapZoneBinaryCallback<A, B, R>(A a, B b); |
| 10 |
| 11 _wrapZoneCallback/*<A, R>*/ _wrapZone/*<A, R>*/(_wrapZoneCallback/*<A, R>*/ call
back) { |
8 // For performance reasons avoid wrapping if we are in the root zone. | 12 // For performance reasons avoid wrapping if we are in the root zone. |
9 if (Zone.current == Zone.ROOT) return callback; | 13 if (Zone.current == Zone.ROOT) return callback; |
10 if (callback == null) return null; | 14 if (callback == null) return null; |
11 return Zone.current.bindUnaryCallback(callback, runGuarded: true); | 15 // TODO(jacobr): we cast to _wrapZoneCallback/*<A, R>*/ to hack around missing |
| 16 // generic method support in zones. |
| 17 return Zone.current.bindUnaryCallback(callback, runGuarded: true) as _wrapZone
Callback/*<A, R>*/; |
12 } | 18 } |
13 | 19 |
14 _wrapBinaryZone(callback(arg1, arg2)) { | 20 _wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(_wrapZoneBinar
yCallback/*<A, B, R>*/ callback) { |
15 if (Zone.current == Zone.ROOT) return callback; | 21 if (Zone.current == Zone.ROOT) return callback; |
16 if (callback == null) return null; | 22 if (callback == null) return null; |
17 return Zone.current.bindBinaryCallback(callback, runGuarded: true); | 23 // We cast to _wrapZoneBinaryCallback/*<A, B, R>*/ to hack around missing |
| 24 // generic method support in zones. |
| 25 return Zone.current.bindBinaryCallback(callback, runGuarded: true) as _wrapZon
eBinaryCallback/*<A, B, R>*/; |
18 } | 26 } |
19 | 27 |
20 /** | 28 /** |
21 * Alias for [querySelector]. Note this function is deprecated because its | 29 * Alias for [querySelector]. Note this function is deprecated because its |
22 * semantics will be changing in the future. | 30 * semantics will be changing in the future. |
23 */ | 31 */ |
24 @deprecated | 32 @deprecated |
25 @Experimental() | 33 @Experimental() |
26 Element query(String relativeSelectors) => document.query(relativeSelectors); | 34 Element query(String relativeSelectors) => document.query(relativeSelectors); |
27 /** | 35 /** |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); | 78 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); |
71 | 79 |
72 /// A utility for changing the Dart wrapper type for elements. | 80 /// A utility for changing the Dart wrapper type for elements. |
73 abstract class ElementUpgrader { | 81 abstract class ElementUpgrader { |
74 /// Upgrade the specified element to be of the Dart type this was created for. | 82 /// Upgrade the specified element to be of the Dart type this was created for. |
75 /// | 83 /// |
76 /// After upgrading the element passed in is invalid and the returned value | 84 /// After upgrading the element passed in is invalid and the returned value |
77 /// should be used instead. | 85 /// should be used instead. |
78 Element upgrade(Element element); | 86 Element upgrade(Element element); |
79 } | 87 } |
OLD | NEW |