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

Unified Diff: lib/html/templates/html/impl/impl_DocumentFragment.darttemplate

Issue 11016015: Removing ElementList. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for dartium? Created 8 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:
View side-by-side diff with in-line comments
Download patch
Index: lib/html/templates/html/impl/impl_DocumentFragment.darttemplate
diff --git a/lib/html/templates/html/impl/impl_DocumentFragment.darttemplate b/lib/html/templates/html/impl/impl_DocumentFragment.darttemplate
index 8636677cb4398e7d01179941758abe236332fc2a..58204ae983db75956ae2b75be8d86e093c70924c 100644
--- a/lib/html/templates/html/impl/impl_DocumentFragment.darttemplate
+++ b/lib/html/templates/html/impl/impl_DocumentFragment.darttemplate
@@ -2,11 +2,11 @@
// 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.
@@ -15,16 +15,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);
}
@@ -135,11 +125,11 @@ class _FrozenCSSClassSet extends _CssClassSet {
}
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
- 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;
}
@@ -184,7 +174,8 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
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);
@@ -233,7 +224,12 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
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;
« no previous file with comments | « lib/html/templates/html/dartium/html_dartium.darttemplate ('k') | lib/html/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698