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

Unified Diff: tools/dom/src/CssClassSet.dart

Issue 18583004: Added boolean to toggle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
« no previous file with comments | « tests/html/element_classes_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/CssClassSet.dart
diff --git a/tools/dom/src/CssClassSet.dart b/tools/dom/src/CssClassSet.dart
index 4ee943da14ef94c36589104946db5aa83374629e..53554462a3d2fd9fdc6d6cf96c5a8f74d4fc1d95 100644
--- a/tools/dom/src/CssClassSet.dart
+++ b/tools/dom/src/CssClassSet.dart
@@ -10,8 +10,11 @@ abstract class CssClassSet implements Set<String> {
/**
* Adds the class [value] to the element if it is not on it, removes it if it
* is.
+ *
+ * If [shouldAdd] is true, then we always add that [value] to the element. If
+ * [shouldAdd] is false then we always remove [value] from the element.
*/
- bool toggle(String value);
+ bool toggle(String value, [bool shouldAdd]);
/**
* Returns [:true:] if classes cannot be added or removed from this
@@ -66,8 +69,11 @@ abstract class CssClassSet implements Set<String> {
* 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/).
+ * If [shouldAdd] is true, then we always add all the classes in [iterable]
+ * element. If [shouldAdd] is false then we always remove all the classes in
+ * [iterable] from the element.
*/
- void toggleAll(Iterable<String> iterable);
+ void toggleAll(Iterable<String> iterable, [bool shouldAdd]);
}
/**
@@ -113,8 +119,8 @@ class _MultiElementCssClassSet extends CssClassSetImpl {
* Adds the class [value] to the element if it is not on it, removes it if it
* is.
*/
- bool toggle(String value) =>
- _modifyWithReturnValue((e) => e.toggle(value));
+ bool toggle(String value, [bool shouldAdd]) =>
+ _modifyWithReturnValue((e) => e.toggle(value, shouldAdd));
/**
* Remove the class [value] from element, and return true on successful
« no previous file with comments | « tests/html/element_classes_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698