| Index: lib/html/dart2js/html_dart2js.dart
|
| diff --git a/lib/html/dart2js/html_dart2js.dart b/lib/html/dart2js/html_dart2js.dart
|
| index dcc8123d38211f738e7a2dad74b09bc63f1e5ce0..8f107edf4c179e89216b64cf88ae87024c89b3a8 100644
|
| --- a/lib/html/dart2js/html_dart2js.dart
|
| +++ b/lib/html/dart2js/html_dart2js.dart
|
| @@ -23,7 +23,7 @@ Document get document() native "return document;";
|
| _DocumentImpl get _document() native "return document;";
|
|
|
| Element query(String selector) => _document.query(selector);
|
| -ElementList queryAll(String selector) => _document.queryAll(selector);
|
| +List<Element> queryAll(String selector) => _document.queryAll(selector);
|
|
|
| // Workaround for tags like <cite> that lack their own Element subclass --
|
| // Dart issue 1990.
|
| @@ -10420,11 +10420,11 @@ abstract class DocumentFragment extends Element {
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -class FilteredElementList implements ElementList {
|
| +class _FilteredElementList implements List {
|
| final Node _node;
|
| final NodeList _childNodes;
|
|
|
| - FilteredElementList(Node node): _childNodes = node.nodes, _node = node;
|
| + _FilteredElementList(Node node): _childNodes = node.nodes, _node = node;
|
|
|
| // We can't memoize this, since it's possible that children will be messed
|
| // with externally to this class.
|
| @@ -10433,16 +10433,6 @@ class FilteredElementList implements ElementList {
|
| List<Element> get _filtered =>
|
| new List.from(_childNodes.filter((n) => n is Element));
|
|
|
| - // Don't use _filtered.first so we can short-circuit once we find an element.
|
| - Element get first {
|
| - for (final node in _childNodes) {
|
| - if (node is Element) {
|
| - return node;
|
| - }
|
| - }
|
| - return null;
|
| - }
|
| -
|
| void forEach(void f(Element element)) {
|
| _filtered.forEach(f);
|
| }
|
| @@ -10553,11 +10543,11 @@ class _FrozenCSSClassSet extends _CssClassSet {
|
| }
|
|
|
| class _DocumentFragmentImpl extends _NodeImpl implements DocumentFragment native "*DocumentFragment" {
|
| - ElementList _elements;
|
| + List<Element> _elements;
|
|
|
| - ElementList get elements {
|
| + List<Element> get elements {
|
| if (_elements == null) {
|
| - _elements = new FilteredElementList(this);
|
| + _elements = new _FilteredElementList(this);
|
| }
|
| return _elements;
|
| }
|
| @@ -10602,7 +10592,8 @@ class _DocumentFragmentImpl extends _NodeImpl implements DocumentFragment native
|
| case "beforebegin": return null;
|
| case "afterend": return null;
|
| case "afterbegin":
|
| - this.insertBefore(node, this.nodes.first);
|
| + var first = this.nodes.length > 0 ? this.nodes[0] : null;
|
| + this.insertBefore(node, first);
|
| return node;
|
| case "beforeend":
|
| this.nodes.add(node);
|
| @@ -10651,7 +10642,12 @@ class _DocumentFragmentImpl extends _NodeImpl implements DocumentFragment native
|
| String get tagName => "";
|
| String get webkitdropzone => "";
|
| String get webkitRegionOverflow => "";
|
| - Element get $m_firstElementChild() => elements.first();
|
| + Element get $m_firstElementChild {
|
| + if (elements.length > 0) {
|
| + return elements[0];
|
| + }
|
| + return null;
|
| + }
|
| Element get $m_lastElementChild() => elements.last();
|
| Element get nextElementSibling => null;
|
| Element get previousElementSibling => null;
|
| @@ -11149,21 +11145,6 @@ class _EXTTextureFilterAnisotropicImpl implements EXTTextureFilterAnisotropic na
|
|
|
| // WARNING: Do not edit - generated code.
|
|
|
| -// TODO(vsm): Eliminate this type.
|
| -
|
| -// Note, ElementList implements List (instead of List<Element>) so
|
| -// that its implementing classes may be cast to Lists of more specific
|
| -// type such as List<CanvasElement>.
|
| -abstract class ElementList implements List {
|
| - // TODO(jacobr): add element batch manipulation methods.
|
| - ElementList filter(bool f(Element element));
|
| -
|
| - ElementList getRange(int start, int length);
|
| -
|
| - Element get first;
|
| - // TODO(jacobr): add insertAt
|
| -}
|
| -
|
| /**
|
| * All your attribute manipulation needs in one place.
|
| * Extends the regular Map interface by automatically coercing non-string
|
| @@ -11220,7 +11201,7 @@ abstract class Element implements Node, NodeSelector {
|
| * @domName childElementCount, firstElementChild, lastElementChild,
|
| * children, Node.nodes.add
|
| */
|
| - ElementList get elements;
|
| + List<Element> get elements;
|
|
|
| void set elements(Collection<Element> value);
|
|
|
| @@ -11569,7 +11550,7 @@ abstract class ElementEvents implements Events {
|
|
|
| // TODO(jacobr): use _Lists.dart to remove some of the duplicated
|
| // functionality.
|
| -class _ChildrenElementList implements ElementList {
|
| +class _ChildrenElementList implements List {
|
| // Raw Element.
|
| final _ElementImpl _element;
|
| final _HTMLCollectionImpl _childElements;
|
| @@ -11586,17 +11567,13 @@ class _ChildrenElementList implements ElementList {
|
| return output;
|
| }
|
|
|
| - _ElementImpl get first {
|
| - return _element.$dom_firstElementChild;
|
| - }
|
| -
|
| void forEach(void f(Element element)) {
|
| for (_ElementImpl element in _childElements) {
|
| f(element);
|
| }
|
| }
|
|
|
| - ElementList filter(bool f(Element element)) {
|
| + List<Element> filter(bool f(Element element)) {
|
| final output = <Element>[];
|
| forEach((Element element) {
|
| if (f(element)) {
|
| @@ -11719,7 +11696,7 @@ class _ChildrenElementList implements ElementList {
|
| // a better option given that we cannot quite force NodeList to be an
|
| // ElementList as there are valid cases where a NodeList JavaScript object
|
| // contains Node objects that are not Elements.
|
| -class _FrozenElementList implements ElementList {
|
| +class _FrozenElementList implements List {
|
| final List<Node> _nodeList;
|
|
|
| _FrozenElementList._wrap(this._nodeList);
|
| @@ -11742,8 +11719,8 @@ class _FrozenElementList implements ElementList {
|
| return out;
|
| }
|
|
|
| - ElementList filter(bool f(Element element)) {
|
| - final out = new _ElementList([]);
|
| + List<Element> filter(bool f(Element element)) {
|
| + final out = <Element>[];
|
| for (Element el in this) {
|
| if (f(el)) out.add(el);
|
| }
|
| @@ -11812,7 +11789,7 @@ class _FrozenElementList implements ElementList {
|
| throw const UnsupportedOperationException('');
|
| }
|
|
|
| - ElementList getRange(int start, int rangeLength) =>
|
| + List<Element> getRange(int start, int rangeLength) =>
|
| new _FrozenElementList._wrap(_nodeList.getRange(start, rangeLength));
|
|
|
| int indexOf(Element element, [int start = 0]) =>
|
| @@ -11856,16 +11833,6 @@ class _FrozenElementListIterator implements Iterator<Element> {
|
| bool hasNext() => _index < _list.length;
|
| }
|
|
|
| -class _ElementList extends _ListWrapper<Element> implements ElementList {
|
| - _ElementList(List<Element> list) : super(list);
|
| -
|
| - ElementList filter(bool f(Element element)) =>
|
| - new _ElementList(super.filter(f));
|
| -
|
| - ElementList getRange(int start, int rangeLength) =>
|
| - new _ElementList(super.getRange(start, rangeLength));
|
| -}
|
| -
|
| class _ElementAttributeMap implements AttributeMap {
|
|
|
| final _ElementImpl _element;
|
| @@ -12253,7 +12220,7 @@ class _ElementImpl extends _NodeImpl implements Element native "*Element" {
|
| elements.addAll(value);
|
| }
|
|
|
| - ElementList get elements => new _ChildrenElementList._wrap(this);
|
| + List<Element> get elements => new _ChildrenElementList._wrap(this);
|
|
|
| _ElementImpl query(String selectors) => $dom_querySelector(selectors);
|
|
|
| @@ -12352,7 +12319,8 @@ class _ElementImpl extends _NodeImpl implements Element native "*Element" {
|
| this.parent.insertBefore(node, this);
|
| break;
|
| case 'afterbegin':
|
| - this.insertBefore(node, this.nodes.first);
|
| + var first = this.nodes.length > 0 ? this.nodes[0] : null;
|
| + this.insertBefore(node, first);
|
| break;
|
| case 'beforeend':
|
| this.nodes.add(node);
|
| @@ -12534,7 +12502,7 @@ class _ElementFactoryProvider {
|
|
|
| Element element;
|
| if (temp.elements.length == 1) {
|
| - element = temp.elements.first;
|
| + element = temp.elements[0];
|
| } else if (parentTag == 'html' && temp.elements.length == 2) {
|
| // Work around for edge case in WebKit and possibly other browsers where
|
| // both body and head elements are created even though the inner html
|
| @@ -21152,10 +21120,10 @@ class _ListWrapper<E> implements List<E> {
|
| class _NodeListWrapper extends _ListWrapper<Node> implements NodeList {
|
| _NodeListWrapper(List list) : super(list);
|
|
|
| - NodeList filter(bool f(Node element)) =>
|
| + List<Node> filter(bool f(Node element)) =>
|
| new _NodeListWrapper(_list.filter(f));
|
|
|
| - NodeList getRange(int start, int rangeLength) =>
|
| + List<Node> getRange(int start, int rangeLength) =>
|
| new _NodeListWrapper(_list.getRange(start, rangeLength));
|
| }
|
|
|
| @@ -21186,7 +21154,7 @@ class _NodeListImpl implements NodeList, JavaScriptIndexingBehavior native "*Nod
|
|
|
| void addAll(Collection<_NodeImpl> collection) {
|
| for (_NodeImpl node in collection) {
|
| - _parent.$dom_appendChild(node);
|
| + _parent.$dom_appendChild(node);
|
| }
|
| }
|
|
|
| @@ -21244,7 +21212,7 @@ class _NodeListImpl implements NodeList, JavaScriptIndexingBehavior native "*Nod
|
| void insertRange(int start, int rangeLength, [Node initialValue]) {
|
| throw new UnsupportedOperationException("Cannot insertRange on immutable List.");
|
| }
|
| - NodeList getRange(int start, int rangeLength) =>
|
| + List<Node> getRange(int start, int rangeLength) =>
|
| new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[]));
|
|
|
| // -- end List<Node> mixins.
|
| @@ -24874,7 +24842,7 @@ class _SVGElementImpl extends _ElementImpl implements SVGElement native "*SVGEle
|
| return _cssClassSet;
|
| }
|
|
|
| - ElementList get elements => new FilteredElementList(this);
|
| + List<Element> get elements => new _FilteredElementList(this);
|
|
|
| void set elements(Collection<Element> value) {
|
| final elements = this.elements;
|
| @@ -24901,7 +24869,7 @@ class _SVGElementImpl extends _ElementImpl implements SVGElement native "*SVGEle
|
| // Wrap the SVG string in <svg> so that SVGElements are created, rather than
|
| // HTMLElements.
|
| container.innerHTML = '<svg version="1.1">$svg</svg>';
|
| - this.elements = container.elements.first.elements;
|
| + this.elements = container.elements[0].elements;
|
| }
|
|
|
|
|
|
|