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

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 12851014: Add toggleAll to CSSClassSet. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 0b6a1cbb7a8b8476fcf28904ef5e0faf65e2eb3e..7b763024492daee694295d5a872ea84829b6c07d 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -30765,7 +30765,7 @@ abstract class CssClassSet implements Set<String> {
}
/**
- * Adds the class [token] to the element if it is not on it, removes it if it
+ * Adds the class [value] to the element if it is not on it, removes it if it
* is.
*/
bool toggle(String value) {
@@ -30819,14 +30819,33 @@ abstract class CssClassSet implements Set<String> {
// interface Collection - END
// interface Set - BEGIN
+ /**
+ * Determine if this element contains the class [value].
+ *
+ * This is the Dart equivalent of jQuery's
+ * [hasClass](http://api.jquery.com/hasClass/).
+ */
bool contains(String value) => readClasses().contains(value);
+ /**
+ * Add the class [value] to element.
+ *
+ * This is the Dart equivalent of jQuery's
+ * [addClass](http://api.jquery.com/addClass/).
+ */
void add(String value) {
// TODO - figure out if we need to do any validation here
// or if the browser natively does enough.
_modify((s) => s.add(value));
}
+ /**
+ * Remove the class [value] from element, and return true on successful
+ * removal.
+ *
+ * This is the Dart equivalent of jQuery's
+ * [removeClass](http://api.jquery.com/removeClass/).
+ */
bool remove(Object value) {
if (value is! String) return false;
Set<String> s = readClasses();
@@ -30835,15 +30854,38 @@ abstract class CssClassSet implements Set<String> {
return result;
}
+ /**
+ * Add all classes specified in [iterable] to element.
+ *
+ * This is the Dart equivalent of jQuery's
+ * [addClass](http://api.jquery.com/addClass/).
+ */
void addAll(Iterable<String> iterable) {
// TODO - see comment above about validation.
_modify((s) => s.addAll(iterable));
}
+ /**
+ * Remove all classes specified in [iterable] from element.
+ *
+ * This is the Dart equivalent of jQuery's
+ * [removeClass](http://api.jquery.com/removeClass/).
+ */
void removeAll(Iterable<String> iterable) {
_modify((s) => s.removeAll(iterable));
}
+ /**
+ * Toggles all classes specified in [iterable] on element.
+ *
+ * Iterate through [iterable]'s items, and add it if it is not on it, or
+ * remove it if it is. This is the Dart equivalent of jQuery's
+ * [toggleClass](http://api.jquery.com/toggleClass/).
+ */
+ void toggleAll(Iterable<String> iterable) {
+ iterable.forEach(toggle);
+ }
+
void retainAll(Iterable<String> iterable) {
_modify((s) => s.retainAll(iterable));
}
« 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