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

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

Side-by-side diff isn't available for this file because of its large size.
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
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ca411a605ed70d4a39ee87a00dec5e4327c0417c 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/*<T>*/ querySelectorAll/*<T extends Element>*/(String selectors) =>
Leaf 2016/04/21 16:41:01 If you care about non-strong mode analysis, you mi
Jacob 2016/04/21 16:53:55 Good catch. Switched to this version everywhere.
+ 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/*<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/*<T>*/ querySelectorAll/*<T extends Element>*/(String selectors) =>
+ new _FrozenElementList/*<T>*/._wrap(_querySelectorAll(selectors));
+
String get innerHtml {
final e = new Element.tag("div");
@@ -12429,17 +12429,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 +12447,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 +12455,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 +13231,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/*<T>*/ querySelectorAll/*<T extends Element>*/(String selectors) =>
+ new _FrozenElementList/*<T>*/._wrap(_querySelectorAll(selectors));
/**
* Alias for [querySelector]. Note this function is deprecated because its
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698