| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of html_common; | 5 part of html_common; |
| 6 | 6 |
| 7 abstract class CssClassSetImpl implements CssClassSet { | 7 abstract class CssClassSetImpl implements CssClassSet { |
| 8 static final RegExp _validTokenRE = new RegExp(r'^\S+$'); | 8 static final RegExp _validTokenRE = new RegExp(r'^\S+$'); |
| 9 | 9 |
| 10 String _validateToken(String value) { | 10 String _validateToken(String value) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 Iterator<String> get iterator => readClasses().iterator; | 48 Iterator<String> get iterator => readClasses().iterator; |
| 49 // interface Iterable - END | 49 // interface Iterable - END |
| 50 | 50 |
| 51 // interface Collection - BEGIN | 51 // interface Collection - BEGIN |
| 52 void forEach(void f(String element)) { | 52 void forEach(void f(String element)) { |
| 53 readClasses().forEach(f); | 53 readClasses().forEach(f); |
| 54 } | 54 } |
| 55 | 55 |
| 56 String join([String separator = ""]) => readClasses().join(separator); | 56 String join([String separator = ""]) => readClasses().join(separator); |
| 57 | 57 |
| 58 Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(String e)) => readClasses().map/*<T>*/(f); | 58 Iterable<T> map<T>(T f(String e)) => readClasses().map<T>(f); |
| 59 | 59 |
| 60 Iterable<String> where(bool f(String element)) => readClasses().where(f); | 60 Iterable<String> where(bool f(String element)) => readClasses().where(f); |
| 61 | 61 |
| 62 Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(String element)) => | 62 Iterable<T> expand<T>(Iterable<T> f(String element)) => |
| 63 readClasses().expand/*<T>*/(f); | 63 readClasses().expand<T>(f); |
| 64 | 64 |
| 65 bool every(bool f(String element)) => readClasses().every(f); | 65 bool every(bool f(String element)) => readClasses().every(f); |
| 66 | 66 |
| 67 bool any(bool f(String element)) => readClasses().any(f); | 67 bool any(bool f(String element)) => readClasses().any(f); |
| 68 | 68 |
| 69 bool get isEmpty => readClasses().isEmpty; | 69 bool get isEmpty => readClasses().isEmpty; |
| 70 | 70 |
| 71 bool get isNotEmpty => readClasses().isNotEmpty; | 71 bool get isNotEmpty => readClasses().isNotEmpty; |
| 72 | 72 |
| 73 int get length => readClasses().length; | 73 int get length => readClasses().length; |
| 74 | 74 |
| 75 String reduce(String combine(String value, String element)) { | 75 String reduce(String combine(String value, String element)) { |
| 76 return readClasses().reduce(combine); | 76 return readClasses().reduce(combine); |
| 77 } | 77 } |
| 78 | 78 |
| 79 dynamic/*=T*/ fold/*<T>*/(var/*=T*/ initialValue, | 79 T fold<T>(T initialValue, T combine(T previousValue, String element)) { |
| 80 dynamic/*=T*/ combine(var/*=T*/ previousValue, String element)) { | 80 return readClasses().fold<T>(initialValue, combine); |
| 81 return readClasses().fold/*<T>*/(initialValue, combine); | |
| 82 } | 81 } |
| 83 | 82 |
| 84 // interface Collection - END | 83 // interface Collection - END |
| 85 | 84 |
| 86 // interface Set - BEGIN | 85 // interface Set - BEGIN |
| 87 /** | 86 /** |
| 88 * Determine if this element contains the class [value]. | 87 * Determine if this element contains the class [value]. |
| 89 * | 88 * |
| 90 * This is the Dart equivalent of jQuery's | 89 * This is the Dart equivalent of jQuery's |
| 91 * [hasClass](http://api.jquery.com/hasClass/). | 90 * [hasClass](http://api.jquery.com/hasClass/). |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 */ | 233 */ |
| 235 Set<String> readClasses(); | 234 Set<String> readClasses(); |
| 236 | 235 |
| 237 /** | 236 /** |
| 238 * Join all the elements of a set into one string and write | 237 * Join all the elements of a set into one string and write |
| 239 * back to the element. | 238 * back to the element. |
| 240 * This is intended to be overridden by specific implementations. | 239 * This is intended to be overridden by specific implementations. |
| 241 */ | 240 */ |
| 242 void writeClasses(Set<String> s); | 241 void writeClasses(Set<String> s); |
| 243 } | 242 } |
| OLD | NEW |