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