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>*/( |
| 12 _wrapZoneCallback/*<A, R>*/ callback) { |
12 // For performance reasons avoid wrapping if we are in the root zone. | 13 // For performance reasons avoid wrapping if we are in the root zone. |
13 if (Zone.current == Zone.ROOT) return callback; | 14 if (Zone.current == Zone.ROOT) return callback; |
14 if (callback == null) return null; | 15 if (callback == null) return null; |
15 return Zone.current.bindUnaryCallback/*<R, A>*/(callback, runGuarded: true); | 16 return Zone.current.bindUnaryCallback/*<R, A>*/(callback, runGuarded: true); |
16 } | 17 } |
17 | 18 |
18 _wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(_wrapZoneBinar
yCallback/*<A, B, R>*/ callback) { | 19 _wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/( |
| 20 _wrapZoneBinaryCallback/*<A, B, R>*/ callback) { |
19 if (Zone.current == Zone.ROOT) return callback; | 21 if (Zone.current == Zone.ROOT) return callback; |
20 if (callback == null) return null; | 22 if (callback == null) return null; |
21 return Zone.current.bindBinaryCallback/*<R, A, B>*/(callback, runGuarded: true
); | 23 return Zone.current |
| 24 .bindBinaryCallback/*<R, A, B>*/(callback, runGuarded: true); |
22 } | 25 } |
23 | 26 |
24 /** | 27 /** |
25 * Alias for [querySelector]. Note this function is deprecated because its | 28 * Alias for [querySelector]. Note this function is deprecated because its |
26 * semantics will be changing in the future. | 29 * semantics will be changing in the future. |
27 */ | 30 */ |
28 @deprecated | 31 @deprecated |
29 @Experimental() | 32 @Experimental() |
30 Element query(String relativeSelectors) => document.query(relativeSelectors); | 33 Element query(String relativeSelectors) => document.query(relativeSelectors); |
31 /** | 34 /** |
32 * Alias for [querySelectorAll]. Note this function is deprecated because its | 35 * Alias for [querySelectorAll]. Note this function is deprecated because its |
33 * semantics will be changing in the future. | 36 * semantics will be changing in the future. |
34 */ | 37 */ |
35 @deprecated | 38 @deprecated |
36 @Experimental() | 39 @Experimental() |
37 ElementList<Element> queryAll(String relativeSelectors) => document.queryAll(rel
ativeSelectors); | 40 ElementList<Element> queryAll(String relativeSelectors) => |
| 41 document.queryAll(relativeSelectors); |
38 | 42 |
39 /** | 43 /** |
40 * Finds the first descendant element of this document that matches the | 44 * Finds the first descendant element of this document that matches the |
41 * specified group of selectors. | 45 * specified group of selectors. |
42 * | 46 * |
43 * Unless your webpage contains multiple documents, the top-level | 47 * Unless your webpage contains multiple documents, the top-level |
44 * [querySelector] | 48 * [querySelector] |
45 * method behaves the same as this method, so you should use it instead to | 49 * method behaves the same as this method, so you should use it instead to |
46 * save typing a few characters. | 50 * save typing a few characters. |
47 * | 51 * |
(...skipping 16 matching lines...) Expand all Loading... |
64 * method behaves the same as this method, so you should use it instead to | 68 * method behaves the same as this method, so you should use it instead to |
65 * save typing a few characters. | 69 * save typing a few characters. |
66 * | 70 * |
67 * [selectors] should be a string using CSS selector syntax. | 71 * [selectors] should be a string using CSS selector syntax. |
68 * | 72 * |
69 * var items = document.querySelectorAll('.itemClassName'); | 73 * var items = document.querySelectorAll('.itemClassName'); |
70 * | 74 * |
71 * For details about CSS selector syntax, see the | 75 * For details about CSS selector syntax, see the |
72 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | 76 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). |
73 */ | 77 */ |
74 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); | 78 ElementList<Element> querySelectorAll(String selectors) => |
| 79 document.querySelectorAll(selectors); |
75 | 80 |
76 /// A utility for changing the Dart wrapper type for elements. | 81 /// A utility for changing the Dart wrapper type for elements. |
77 abstract class ElementUpgrader { | 82 abstract class ElementUpgrader { |
78 /// 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. |
79 /// | 84 /// |
80 /// 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 |
81 /// should be used instead. | 86 /// should be used instead. |
82 Element upgrade(Element element); | 87 Element upgrade(Element element); |
83 } | 88 } |
OLD | NEW |