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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(String value) => readClasses().contains(value); |
85 | 85 |
| 86 /** Lookup from the Set interface. Not interesting for a String set. */ |
| 87 E lookup(String value) => contains(value) ? value : null; |
| 88 |
86 /** | 89 /** |
87 * Add the class [value] to element. | 90 * Add the class [value] to element. |
88 * | 91 * |
89 * This is the Dart equivalent of jQuery's | 92 * This is the Dart equivalent of jQuery's |
90 * [addClass](http://api.jquery.com/addClass/). | 93 * [addClass](http://api.jquery.com/addClass/). |
91 */ | 94 */ |
92 void add(String value) { | 95 void add(String value) { |
93 // TODO - figure out if we need to do any validation here | 96 // TODO - figure out if we need to do any validation here |
94 // or if the browser natively does enough. | 97 // or if the browser natively does enough. |
95 modify((s) => s.add(value)); | 98 modify((s) => s.add(value)); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 */ | 219 */ |
217 Set<String> readClasses(); | 220 Set<String> readClasses(); |
218 | 221 |
219 /** | 222 /** |
220 * Join all the elements of a set into one string and write | 223 * Join all the elements of a set into one string and write |
221 * back to the element. | 224 * back to the element. |
222 * This is intended to be overridden by specific implementations. | 225 * This is intended to be overridden by specific implementations. |
223 */ | 226 */ |
224 void writeClasses(Set<String> s); | 227 void writeClasses(Set<String> s); |
225 } | 228 } |
OLD | NEW |