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 return Zone.current.bindUnaryCallback/*<R, A>*/(callback, runGuarded: true); |
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 } | 16 } |
22 | 17 |
23 _wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(_wrapZoneBinar
yCallback/*<A, B, R>*/ callback) { | 18 _wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(_wrapZoneBinar
yCallback/*<A, B, R>*/ callback) { |
24 if (Zone.current == Zone.ROOT) return callback; | 19 if (Zone.current == Zone.ROOT) return callback; |
25 if (callback == null) return null; | 20 if (callback == null) return null; |
26 // We cast to _wrapZoneBinaryCallback/*<A, B, R>*/ to hack around missing | 21 return Zone.current.bindBinaryCallback/*<R, A, B>*/(callback, runGuarded: true
); |
27 // generic method support in zones. | |
28 // ignore: STRONG_MODE_DOWN_CAST_COMPOSITE | |
29 _wrapZoneBinaryCallback/*<A, B, R>*/ wrapped = | |
30 Zone.current.bindBinaryCallback(callback, runGuarded: true); | |
31 return wrapped; | |
32 } | 22 } |
33 | 23 |
34 /** | 24 /** |
35 * Alias for [querySelector]. Note this function is deprecated because its | 25 * Alias for [querySelector]. Note this function is deprecated because its |
36 * semantics will be changing in the future. | 26 * semantics will be changing in the future. |
37 */ | 27 */ |
38 @deprecated | 28 @deprecated |
39 @Experimental() | 29 @Experimental() |
40 Element query(String relativeSelectors) => document.query(relativeSelectors); | 30 Element query(String relativeSelectors) => document.query(relativeSelectors); |
41 /** | 31 /** |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); | 74 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); |
85 | 75 |
86 /// A utility for changing the Dart wrapper type for elements. | 76 /// A utility for changing the Dart wrapper type for elements. |
87 abstract class ElementUpgrader { | 77 abstract class ElementUpgrader { |
88 /// Upgrade the specified element to be of the Dart type this was created for. | 78 /// Upgrade the specified element to be of the Dart type this was created for. |
89 /// | 79 /// |
90 /// After upgrading the element passed in is invalid and the returned value | 80 /// After upgrading the element passed in is invalid and the returned value |
91 /// should be used instead. | 81 /// should be used instead. |
92 Element upgrade(Element element); | 82 Element upgrade(Element element); |
93 } | 83 } |
OLD | NEW |