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