| Index: sdk/lib/html/html_common/css_class_set.dart
|
| diff --git a/sdk/lib/html/html_common/css_class_set.dart b/sdk/lib/html/html_common/css_class_set.dart
|
| index 18a80e71c998491195b0f1b6362b45a411583b75..dddf69f00accf9dc00569057a694bb0ed51b7c6d 100644
|
| --- a/sdk/lib/html/html_common/css_class_set.dart
|
| +++ b/sdk/lib/html/html_common/css_class_set.dart
|
| @@ -13,15 +13,19 @@ abstract class CssClassSetImpl implements CssClassSet {
|
| /**
|
| * 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]) {
|
| Set<String> s = readClasses();
|
| bool result = false;
|
| - if (s.contains(value)) {
|
| - s.remove(value);
|
| - } else {
|
| + if (shouldAdd == null) shouldAdd = !s.contains(value);
|
| + if (shouldAdd) {
|
| s.add(value);
|
| result = true;
|
| + } else {
|
| + s.remove(value);
|
| }
|
| writeClasses(s);
|
| return result;
|
| @@ -133,9 +137,12 @@ abstract class CssClassSetImpl implements CssClassSet {
|
| * 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) {
|
| - iterable.forEach(toggle);
|
| + void toggleAll(Iterable<String> iterable, [bool shouldAdd]) {
|
| + iterable.forEach((e) => toggle(e, shouldAdd));
|
| }
|
|
|
| void retainAll(Iterable<String> iterable) {
|
|
|