Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Side-by-side diff isn't available for this file because of its large size.
Issue 27223003: Deprecate query and queryAll, also add back querySelector and querySelectorAll. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/docs/docs.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 97a6b9a59704f13bf64d5c96b6c4925bdde64540..68a17a911f4268c3791d25b21f1997cead5521ae 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -93,9 +93,23 @@ HtmlDocument get document {
return _document;
}
+/**
+ * Alias for [querySelector]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+@deprecated
+@Experimental()
+Element query(String relativeSelectors) => document.query(relativeSelectors);
+/**
+ * Alias for [querySelectorAll]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+@deprecated
+@Experimental()
+ElementList queryAll(String relativeSelectors) => document.queryAll(relativeSelectors);
-Element query(String selector) => document.query(selector);
-ElementList queryAll(String selector) => document.queryAll(selector);
+Element querySelector(String selector) => document.querySelector(selector);
+ElementList querySelectorAll(String selector) => document.querySelectorAll(selector);
int _getNewIsolateId() => _Utils._getNewIsolateId();
@@ -7929,23 +7943,24 @@ class Document extends Node
String queryCommandValue(String command) native "Document_queryCommandValue_Callback";
/**
- * Finds the first descendant element of this document that matches the
- * specified group of selectors.
- *
- * Unless your webpage contains multiple documents, the top-level query
- * method behaves the same as this method, so you should use it instead to
- * save typing a few characters.
- *
- * [selectors] should be a string using CSS selector syntax.
- * var element1 = document.query('.className');
- * var element2 = document.query('#id');
- *
- * For details about CSS selector syntax, see the
- * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
- */
+ * Finds the first descendant element of this document that matches the
+ * specified group of selectors.
+ *
+ * Unless your webpage contains multiple documents, the top-level
+ * [querySelector]
+ * method behaves the same as this method, so you should use it instead to
+ * save typing a few characters.
+ *
+ * [selectors] should be a string using CSS selector syntax.
+ * var element1 = document.querySelector('.className');
+ * var element2 = document.querySelector('#id');
+ *
+ * For details about CSS selector syntax, see the
+ * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
+ */
@DomName('Document.querySelector')
@DocsEditable()
- Element query(String selectors) native "Document_querySelector_Callback";
+ Element querySelector(String selectors) native "Document_querySelector_Callback";
@DomName('Document.querySelectorAll')
@DocsEditable()
@@ -8234,20 +8249,40 @@ class Document extends Node
* Finds all descendant elements of this document that match the specified
* group of selectors.
*
- * Unless your webpage contains multiple documents, the top-level queryAll
+ * Unless your webpage contains multiple documents, the top-level
+ * [querySelectorAll]
* method behaves the same as this method, so you should use it instead to
* save typing a few characters.
*
* [selectors] should be a string using CSS selector syntax.
- * var items = document.queryAll('.itemClassName');
+ * var items = document.querySelectorAll('.itemClassName');
*
* For details about CSS selector syntax, see the
* [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
*/
- ElementList queryAll(String selectors) {
+ ElementList querySelectorAll(String selectors) {
return new _FrozenElementList._wrap(_querySelectorAll(selectors));
}
+ /**
+ * Alias for [querySelector]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+ @deprecated
+ @Experimental()
+ @DomName('Document.querySelector')
+ Element query(String relativeSelectors) => querySelector(relativeSelectors);
+
+ /**
+ * Alias for [querySelectorAll]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+ @deprecated
+ @Experimental()
+ @DomName('Document.querySelectorAll')
+ ElementList queryAll(String relativeSelectors) =>
+ querySelectorAll(relativeSelectors);
+
/// Checks if [register] is supported on the current platform.
bool get supportsRegister {
return true;
@@ -8303,11 +8338,11 @@ class DocumentFragment extends Node implements ParentNode {
children.addAll(copy);
}
- Element query(String selectors) => _querySelector(selectors);
-
- List<Element> queryAll(String selectors) =>
+ ElementList querySelectorAll(String selectors) =>
new _FrozenElementList._wrap(_querySelectorAll(selectors));
+
+
String get innerHtml {
final e = new Element.tag("div");
e.append(this.clone(true));
@@ -8343,12 +8378,33 @@ class DocumentFragment extends Node implements ParentNode {
this.append(new DocumentFragment.html(text));
}
+ /**
+ * Alias for [querySelector]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+ @deprecated
+ @Experimental()
+ @DomName('DocumentFragment.querySelector')
+ Element query(String relativeSelectors) {
+ return querySelector(relativeSelectors);
+ }
+
+ /**
+ * Alias for [querySelectorAll]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+ @deprecated
+ @Experimental()
+ @DomName('DocumentFragment.querySelectorAll')
+ ElementList queryAll(String relativeSelectors) {
+ return querySelectorAll(relativeSelectors);
+ }
// To suppress missing implicit constructor warnings.
factory DocumentFragment._() { throw new UnsupportedError("Not supported"); }
@DomName('DocumentFragment.querySelector')
@DocsEditable()
- Element _querySelector(String selectors) native "DocumentFragment_querySelector_Callback";
+ Element querySelector(String selectors) native "DocumentFragment_querySelector_Callback";
@DomName('DocumentFragment.querySelectorAll')
@DocsEditable()
@@ -9702,11 +9758,31 @@ abstract class Element extends Node implements ParentNode, ChildNode {
*
* [selectors] should be a string using CSS selector syntax.
*
- * var items = element.query('.itemClassName');
+ * var items = element.querySelectorAll('.itemClassName');
*/
- ElementList queryAll(String selectors) =>
+ @DomName('Element.querySelectorAll')
+ ElementList querySelectorAll(String selectors) =>
new _FrozenElementList._wrap(_querySelectorAll(selectors));
+ /**
+ * Alias for [querySelector]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+ @deprecated
+ @DomName('Element.querySelector')
+ @Experimental()
+ Element query(String relativeSelectors) => querySelector(relativeSelectors);
+
+ /**
+ * Alias for [querySelectorAll]. Note this function is deprecated because its
+ * semantics will be changing in the future.
+ */
+ @deprecated
+ @DomName('Element.querySelectorAll')
+ @Experimental()
+ ElementList queryAll(String relativeSelectors) =>
+ querySelectorAll(relativeSelectors);
+
/**
* The set of CSS classes applied to this element.
*
@@ -10756,25 +10832,25 @@ abstract class Element extends Node implements ParentNode, ChildNode {
bool _hasAttributeNS(String namespaceURI, String localName) native "Element_hasAttributeNS_Callback";
/**
- * Finds the first descendant element of this element that matches the
- * specified group of selectors.
- *
- * [selectors] should be a string using CSS selector syntax.
- *
- * // Gets the first descendant with the class 'classname'
- * var element = element.query('.className');
- * // Gets the element with id 'id'
- * var element = element.query('#id');
- * // Gets the first descendant [ImageElement]
- * var img = element.query('img');
- *
- * See also:
- *
- * * [CSS Selectors](http://docs.webplatform.org/wiki/css/selectors)
- */
+ * Finds the first descendant element of this element that matches the
+ * specified group of selectors.
+ *
+ * [selectors] should be a string using CSS selector syntax.
+ *
+ * // Gets the first descendant with the class 'classname'
+ * var element = element.querySelector('.className');
+ * // Gets the element with id 'id'
+ * var element = element.querySelector('#id');
+ * // Gets the first descendant [ImageElement]
+ * var img = element.querySelector('img');
+ *
+ * See also:
+ *
+ * * [CSS Selectors](http://docs.webplatform.org/wiki/css/selectors)
+ */
@DomName('Element.querySelector')
@DocsEditable()
- Element query(String selectors) native "Element_querySelector_Callback";
+ Element querySelector(String selectors) native "Element_querySelector_Callback";
@DomName('Element.querySelectorAll')
@DocsEditable()
@@ -22811,8 +22887,8 @@ class SelectElement extends HtmlElement {
// Override default options, since IE returns SelectElement itself and it
// does not operate as a List.
List<OptionElement> get options {
- var options =
- this.queryAll('option').where((e) => e is OptionElement).toList();
+ var options = this.querySelectorAll('option').where(
+ (e) => e is OptionElement).toList();
return new UnmodifiableListView(options);
}
@@ -25143,7 +25219,8 @@ class TemplateElement extends HtmlElement {
// Need to do this first as the contents may get lifted if |node| is
// template.
// TODO(jmesserly): content is DocumentFragment or Element
- var descendents = (content as dynamic).queryAll(_allTemplatesSelectors);
+ var descendents =
+ (content as dynamic).querySelectorAll(_allTemplatesSelectors);
if (content is Element && (content as Element).isTemplate) {
_bootstrap(content);
}
@@ -26565,13 +26642,13 @@ class Url extends NativeFieldWrapperClass1 {
if ((blob_OR_source_OR_stream is Blob || blob_OR_source_OR_stream == null)) {
return _createObjectURL_1(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) {
+ if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) {
return _createObjectURL_2(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) {
+ if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) {
Jacob 2013/10/15 22:27:47 why did these lines change? seems unrelated to thi
Emily Fortuna 2013/10/15 22:41:28 It's because of this bug: https://code.google.com/
return _createObjectURL_3(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) {
+ if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) {
return _createObjectURL_4(blob_OR_source_OR_stream);
}
throw new ArgumentError("Incorrect number or type of arguments");
@@ -34868,7 +34945,7 @@ class Platform {
static void upgradeCustomElements(Node node) {
// no-op, provided for dart2js polyfill.
if (node is Element) {
- (node as Element).queryAll('*');
+ (node as Element).querySelectorAll('*');
} else {
node.nodes.forEach(upgradeCustomElements);
}
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/docs/docs.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698