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 | 8 |
9 String toString() { | 9 String toString() { |
10 return readClasses().join(' '); | 10 return readClasses().join(' '); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 // interface Collection - END | 75 // interface Collection - END |
76 | 76 |
77 // interface Set - BEGIN | 77 // interface Set - BEGIN |
78 /** | 78 /** |
79 * Determine if this element contains the class [value]. | 79 * Determine if this element contains the class [value]. |
80 * | 80 * |
81 * This is the Dart equivalent of jQuery's | 81 * This is the Dart equivalent of jQuery's |
82 * [hasClass](http://api.jquery.com/hasClass/). | 82 * [hasClass](http://api.jquery.com/hasClass/). |
83 */ | 83 */ |
84 bool contains(String value) => readClasses().contains(value); | 84 bool contains(Object value) => readClasses().contains(value); |
85 | 85 |
86 /** Lookup from the Set interface. Not interesting for a String set. */ | 86 /** Lookup from the Set interface. Not interesting for a String set. */ |
87 String lookup(String value) => contains(value) ? value : null; | 87 String lookup(Object value) => contains(value) ? value : null; |
88 | 88 |
89 /** | 89 /** |
90 * Add the class [value] to element. | 90 * Add the class [value] to element. |
91 * | 91 * |
92 * This is the Dart equivalent of jQuery's | 92 * This is the Dart equivalent of jQuery's |
93 * [addClass](http://api.jquery.com/addClass/). | 93 * [addClass](http://api.jquery.com/addClass/). |
94 */ | 94 */ |
95 bool add(String value) { | 95 bool add(String value) { |
96 // TODO - figure out if we need to do any validation here | 96 // TODO - figure out if we need to do any validation here |
97 // or if the browser natively does enough. | 97 // or if the browser natively does enough. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 String get single => readClasses().single; | 177 String get single => readClasses().single; |
178 List<String> toList({ bool growable: true }) => | 178 List<String> toList({ bool growable: true }) => |
179 readClasses().toList(growable: growable); | 179 readClasses().toList(growable: growable); |
180 Set<String> toSet() => readClasses().toSet(); | 180 Set<String> toSet() => readClasses().toSet(); |
181 Iterable<String> take(int n) => readClasses().take(n); | 181 Iterable<String> take(int n) => readClasses().take(n); |
182 Iterable<String> takeWhile(bool test(String value)) => | 182 Iterable<String> takeWhile(bool test(String value)) => |
183 readClasses().takeWhile(test); | 183 readClasses().takeWhile(test); |
184 Iterable<String> skip(int n) => readClasses().skip(n); | 184 Iterable<String> skip(int n) => readClasses().skip(n); |
185 Iterable<String> skipWhile(bool test(String value)) => | 185 Iterable<String> skipWhile(bool test(String value)) => |
186 readClasses().skipWhile(test); | 186 readClasses().skipWhile(test); |
187 dynamic firstWhere(bool test(String value), { Object orElse() }) => | 187 String firstWhere(bool test(String value), { String orElse() }) => |
188 readClasses().firstWhere(test, orElse: orElse); | 188 readClasses().firstWhere(test, orElse: orElse); |
189 dynamic lastWhere(bool test(String value), { Object orElse()}) => | 189 String lastWhere(bool test(String value), { String orElse()}) => |
190 readClasses().lastWhere(test, orElse: orElse); | 190 readClasses().lastWhere(test, orElse: orElse); |
191 String singleWhere(bool test(String value)) => | 191 String singleWhere(bool test(String value)) => |
192 readClasses().singleWhere(test); | 192 readClasses().singleWhere(test); |
193 String elementAt(int index) => readClasses().elementAt(index); | 193 String elementAt(int index) => readClasses().elementAt(index); |
194 | 194 |
195 void clear() { | 195 void clear() { |
196 modify((s) => s.clear()); | 196 modify((s) => s.clear()); |
197 } | 197 } |
198 // interface Set - END | 198 // interface Set - END |
199 | 199 |
(...skipping 20 matching lines...) Expand all Loading... |
220 */ | 220 */ |
221 Set<String> readClasses(); | 221 Set<String> readClasses(); |
222 | 222 |
223 /** | 223 /** |
224 * Join all the elements of a set into one string and write | 224 * Join all the elements of a set into one string and write |
225 * back to the element. | 225 * back to the element. |
226 * This is intended to be overridden by specific implementations. | 226 * This is intended to be overridden by specific implementations. |
227 */ | 227 */ |
228 void writeClasses(Set<String> s); | 228 void writeClasses(Set<String> s); |
229 } | 229 } |
OLD | NEW |