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 9ce36d608a640827c9bd66104b7f798550a4c6a7..1eb8613ce9f6496503366dd5e597a29f9cd4da01 100644 |
--- a/sdk/lib/html/dart2js/html_dart2js.dart |
+++ b/sdk/lib/html/dart2js/html_dart2js.dart |
@@ -10110,6 +10110,12 @@ class _FrozenElementList extends ListBase |
new _CssStyleDeclarationSet(this); |
void set classes(Iterable<String> value) { |
+ // TODO(sra): This might be faster for Sets: |
+ // |
+ // new _MultiElementCssClassSet(this).writeClasses(value) |
+ // |
+ // as the code below converts the Iterable[value] to a string multiple |
+ // times. Maybe compute the string and set className here. |
_nodeList.forEach((e) => e.classes = value); |
} |
@@ -10907,6 +10913,8 @@ abstract class Element extends Node implements GlobalEventHandlers, ParentNode, |
CssClassSet get classes => new _ElementCssClassSet(this); |
void set classes(Iterable<String> value) { |
+ // TODO(sra): Do this without reading the classes in clear() and addAll(), |
+ // or writing the classes in clear(). |
CssClassSet classSet = classes; |
classSet.clear(); |
classSet.addAll(value); |
@@ -16587,7 +16595,7 @@ class HttpRequest extends HttpRequestEventTarget { |
static Future<String> getString(String url, |
{bool withCredentials, void onProgress(ProgressEvent e)}) { |
return request(url, withCredentials: withCredentials, |
- onProgress: onProgress).then((xhr) => xhr.responseText); |
+ onProgress: onProgress).then((HttpRequest xhr) => xhr.responseText); |
} |
/** |
@@ -34499,12 +34507,13 @@ class _MultiElementCssClassSet extends CssClassSetImpl { |
Set<String> readClasses() { |
var s = new LinkedHashSet<String>(); |
- _elementCssClassSetIterable.forEach((e) => s.addAll(e.readClasses())); |
+ _elementCssClassSetIterable.forEach( |
+ (_ElementCssClassSet e) => s.addAll(e.readClasses())); |
return s; |
} |
void writeClasses(Set<String> s) { |
- var classes = new List.from(s).join(' '); |
+ var classes = s.join(' '); |
for (Element e in _elementIterable) { |
e.className = classes; |
} |
@@ -34520,7 +34529,7 @@ class _MultiElementCssClassSet extends CssClassSetImpl { |
* className property of this element. |
*/ |
modify( f(Set<String> s)) { |
- _elementCssClassSetIterable.forEach((e) => e.modify(f)); |
+ _elementCssClassSetIterable.forEach((_ElementCssClassSet e) => e.modify(f)); |
} |
/** |
@@ -34528,7 +34537,9 @@ class _MultiElementCssClassSet extends CssClassSetImpl { |
* is. |
*/ |
bool toggle(String value, [bool shouldAdd]) => |
- _modifyWithReturnValue((e) => e.toggle(value, shouldAdd)); |
+ _elementCssClassSetIterable.fold(false, |
+ (bool changed, _ElementCssClassSet e) => |
+ e.toggle(value, shouldAdd) || changed); |
/** |
* Remove the class [value] from element, and return true on successful |
@@ -34537,10 +34548,8 @@ class _MultiElementCssClassSet extends CssClassSetImpl { |
* This is the Dart equivalent of jQuery's |
* [removeClass](http://api.jquery.com/removeClass/). |
*/ |
- bool remove(Object value) => _modifyWithReturnValue((e) => e.remove(value)); |
- |
- bool _modifyWithReturnValue(f) => _elementCssClassSetIterable.fold( |
- false, (prevValue, element) => f(element) || prevValue); |
+ bool remove(Object value) => _elementCssClassSetIterable.fold(false, |
+ (bool changed, _ElementCssClassSet e) => e.remove(value) || changed); |
} |
class _ElementCssClassSet extends CssClassSetImpl { |
@@ -34563,7 +34572,6 @@ class _ElementCssClassSet extends CssClassSetImpl { |
} |
void writeClasses(Set<String> s) { |
- List list = new List.from(s); |
_element.className = s.join(' '); |
} |
} |