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

Unified Diff: sdk/lib/html/html_common/css_class_set.dart

Issue 1098073003: Revert "Enforce token syntax for CssClassSet arguments" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/element_classes_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 aab1d8821fadcc18fad30ea2386b37a4a1debce3..0380d2d82e21e977a15da7c8731f5ecc337b6400 100644
--- a/sdk/lib/html/html_common/css_class_set.dart
+++ b/sdk/lib/html/html_common/css_class_set.dart
@@ -6,13 +6,6 @@ part of html_common;
abstract class CssClassSetImpl implements CssClassSet {
- final RegExp _validTokenRE = new RegExp(r'^\S+$');
-
- String _validateToken(String value) {
- if (_validTokenRE.hasMatch(value)) return value;
- throw new ArgumentError.value(value, 'value', 'Not a valid class token');
- }
-
String toString() {
return readClasses().join(' ');
}
@@ -25,7 +18,6 @@ abstract class CssClassSetImpl implements CssClassSet {
* [shouldAdd] is false then we always remove [value] from the element.
*/
bool toggle(String value, [bool shouldAdd]) {
- _validateToken(value);
Set<String> s = readClasses();
bool result = false;
if (shouldAdd == null) shouldAdd = !s.contains(value);
@@ -89,11 +81,7 @@ abstract class CssClassSetImpl implements CssClassSet {
* This is the Dart equivalent of jQuery's
* [hasClass](http://api.jquery.com/hasClass/).
*/
- bool contains(Object value) {
- if (value is! String) return false;
- _validateToken(value);
- return readClasses().contains(value);
- }
+ bool contains(Object value) => readClasses().contains(value);
/** Lookup from the Set interface. Not interesting for a String set. */
String lookup(Object value) => contains(value) ? value : null;
@@ -105,7 +93,6 @@ abstract class CssClassSetImpl implements CssClassSet {
* [addClass](http://api.jquery.com/addClass/).
*/
bool add(String value) {
- _validateToken(value);
// TODO - figure out if we need to do any validation here
// or if the browser natively does enough.
return modify((s) => s.add(value));
@@ -119,7 +106,6 @@ abstract class CssClassSetImpl implements CssClassSet {
* [removeClass](http://api.jquery.com/removeClass/).
*/
bool remove(Object value) {
- _validateToken(value);
if (value is! String) return false;
Set<String> s = readClasses();
bool result = s.remove(value);
@@ -135,7 +121,7 @@ abstract class CssClassSetImpl implements CssClassSet {
*/
void addAll(Iterable<String> iterable) {
// TODO - see comment above about validation.
- modify((s) => s.addAll(iterable.map(_validateToken)));
+ modify((s) => s.addAll(iterable));
}
/**
@@ -145,7 +131,7 @@ abstract class CssClassSetImpl implements CssClassSet {
* [removeClass](http://api.jquery.com/removeClass/).
*/
void removeAll(Iterable<Object> iterable) {
- modify((s) => s.removeAll(iterable.map(_validateToken)));
+ modify((s) => s.removeAll(iterable));
}
/**
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/element_classes_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698