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

Unified Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 14965003: "Reverting 22400" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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: tools/dom/templates/html/impl/impl_Element.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
index 08a6b089b464da0343d87cc98e2328cb7c54bd49..3b3ca0b26dfd5e8516cdd8d37fc41303a0d3d918 100644
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
@@ -137,32 +137,11 @@ class _ChildrenElementList extends ListBase<Element> {
}
}
-/**
- * An immutable list containing HTML elements. This list contains some
- * additional methods for ease of CSS manipulation on a group of elements.
- */
-abstract class ElementList<T extends Element> extends ListBase<T> {
- /**
- * The union of all CSS classes applied to the elements in this list.
- *
- * This set makes it easy to add, remove or toggle (add if not present, remove
- * if present) the classes applied to a collection of elements.
- *
- * htmlList.classes.add('selected');
- * htmlList.classes.toggle('isOnline');
- * htmlList.classes.remove('selected');
- */
- CssClassSet get classes;
-
- /** Replace the classes with `value` for every element in this list. */
- set classes(Iterable<String> value);
-}
-
// TODO(jacobr): this is an inefficient implementation but it is hard to see
// 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<T extends Element> extends ListBase<T> implements ElementList {
+class _FrozenElementList<T extends Element> extends ListBase<T> {
final List<Node> _nodeList;
_FrozenElementList._wrap(this._nodeList);
@@ -188,12 +167,30 @@ class _FrozenElementList<T extends Element> extends ListBase<T> implements Eleme
Element get last => _nodeList.last;
Element get single => _nodeList.single;
+}
- CssClassSet get classes => new _MultiElementCssClassSet(
- _nodeList.where((e) => e is Element));
+class _ElementCssClassSet extends CssClassSet {
- void set classes(Iterable<String> value) {
- _nodeList.where((e) => e is Element).forEach((e) => e.classes = value);
+ final Element _element;
+
+ _ElementCssClassSet(this._element);
+
+ Set<String> readClasses() {
+ var s = new LinkedHashSet<String>();
+ var classname = _element.$dom_className;
+
+ for (String name in classname.split(' ')) {
+ String trimmed = name.trim();
+ if (!trimmed.isEmpty) {
+ s.add(trimmed);
+ }
+ }
+ return s;
+ }
+
+ void writeClasses(Set<String> s) {
+ List list = new List.from(s);
+ _element.$dom_className = s.join(' ');
}
}
@@ -292,7 +289,7 @@ $(ANNOTATIONS)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
*
* var items = element.query('.itemClassName');
*/
- ElementList queryAll(String selectors) =>
+ List<Element> queryAll(String selectors) =>
new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
/**
« no previous file with comments | « tools/dom/templates/html/impl/impl_Document.darttemplate ('k') | tools/dom/templates/html/impl/impl_SVGElement.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698