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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 1904903003: Make querySelectorAll a generic method so that checked mode behavior is consistent with existing be… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index fe1c960fbf322a45b60d7147e5cab52a28bdc376..de9b7ba34dad77d9577b3bffccfb3b2bf9e695cf 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -10606,9 +10606,8 @@ class Document extends Node
* For details about CSS selector syntax, see the
* [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
*/
- ElementList<Element> querySelectorAll(String selectors) {
- return new _FrozenElementList._wrap(_querySelectorAll(selectors));
- }
+ ElementList<Element /*=T*/> querySelectorAll/*<T extends Element>*/(String selectors) =>
+ new _FrozenElementList/*<T>*/._wrap(_querySelectorAll(selectors));
/**
* Alias for [querySelector]. Note this function is deprecated because its
@@ -10626,7 +10625,7 @@ class Document extends Node
@deprecated
@Experimental()
@DomName('Document.querySelectorAll')
- ElementList<Element> queryAll(String relativeSelectors) =>
+ ElementList<Element /*=T*/> queryAll/*<T extends Element>*/(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
/// Checks if [registerElement] is supported on the current platform.
@@ -10744,8 +10743,9 @@ class DocumentFragment extends Node implements NonElementParentNode, ParentNode
* For details about CSS selector syntax, see the
* [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
*/
- ElementList<Element> querySelectorAll(String selectors) =>
- new _FrozenElementList._wrap(_querySelectorAll(selectors));
+ ElementList<Element /*=T*/> querySelectorAll/*<T extends Element>*/(String selectors) =>
+ new _FrozenElementList/*<T>*/._wrap(_querySelectorAll(selectors));
+
String get innerHtml {
final e = new Element.tag("div");
@@ -10802,9 +10802,8 @@ class DocumentFragment extends Node implements NonElementParentNode, ParentNode
@deprecated
@Experimental()
@DomName('DocumentFragment.querySelectorAll')
- ElementList<Element> queryAll(String relativeSelectors) {
- return querySelectorAll(relativeSelectors);
- }
+ ElementList<Element /*=T*/> queryAll/*<T extends Element>*/(String relativeSelectors) =>
+ querySelectorAll(relativeSelectors);
// To suppress missing implicit constructor warnings.
factory DocumentFragment._() { throw new UnsupportedError("Not supported"); }
@@ -12429,17 +12428,17 @@ abstract class ElementList<T extends Element> extends ListBase<T> {
// declared to return `ElementList`. This provides all the static analysis
// benefit so there is no need for this class have a constrained type parameter.
//
-class _FrozenElementList extends ListBase<Element>
- implements ElementList<Element>, NodeListWrapper {
+class _FrozenElementList<E extends Element> extends ListBase<E>
+ implements ElementList<E>, NodeListWrapper {
final List<Node> _nodeList;
_FrozenElementList._wrap(this._nodeList);
int get length => _nodeList.length;
- Element operator [](int index) => _nodeList[index];
+ E operator [](int index) => _nodeList[index] as E;
- void operator []=(int index, Element value) {
+ void operator []=(int index, E value) {
throw new UnsupportedError('Cannot modify list');
}
@@ -12447,7 +12446,7 @@ class _FrozenElementList extends ListBase<Element>
throw new UnsupportedError('Cannot modify list');
}
- void sort([Comparator<Element> compare]) {
+ void sort([Comparator<E> compare]) {
throw new UnsupportedError('Cannot sort list');
}
@@ -12455,11 +12454,11 @@ class _FrozenElementList extends ListBase<Element>
throw new UnsupportedError('Cannot shuffle list');
}
- Element get first => _nodeList.first;
+ E get first => _nodeList.first as E;
- Element get last => _nodeList.last;
+ E get last => _nodeList.last as E;
- Element get single => _nodeList.single;
+ E get single => _nodeList.single as E;
CssClassSet get classes => new _MultiElementCssClassSet(this);
@@ -13231,8 +13230,8 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
* [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
*/
@DomName('Element.querySelectorAll')
- ElementList<Element> querySelectorAll(String selectors) =>
- new _FrozenElementList._wrap(_querySelectorAll(selectors));
+ ElementList<Element /*=T*/> querySelectorAll/*<T extends Element>*/(String selectors) =>
+ new _FrozenElementList/*<T>*/._wrap(_querySelectorAll(selectors));
/**
* Alias for [querySelector]. Note this function is deprecated because its
@@ -13250,7 +13249,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
@deprecated
@DomName('Element.querySelectorAll')
@Experimental()
- ElementList<Element> queryAll(String relativeSelectors) =>
+ ElementList<Element /*=T*/> queryAll/*<T extends Element>*/(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
/**
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('J')

Powered by Google App Engine
This is Rietveld 408576698