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; | 5 part of html; |
6 | 6 |
7 abstract class CssClassSet implements Set<String> { | 7 abstract class CssClassSet implements Set<String> { |
8 | 8 |
9 String toString() { | 9 String toString() { |
10 return Strings.join(new List.from(readClasses()), ' '); | 10 return Strings.join(new List.from(readClasses()), ' '); |
(...skipping 26 matching lines...) Expand all Loading... |
37 Iterator<String> get iterator => readClasses().iterator; | 37 Iterator<String> get iterator => readClasses().iterator; |
38 // interface Iterable - END | 38 // interface Iterable - END |
39 | 39 |
40 // interface Collection - BEGIN | 40 // interface Collection - BEGIN |
41 void forEach(void f(String element)) { | 41 void forEach(void f(String element)) { |
42 readClasses().forEach(f); | 42 readClasses().forEach(f); |
43 } | 43 } |
44 | 44 |
45 String join([String separator]) => readClasses().join(separator); | 45 String join([String separator]) => readClasses().join(separator); |
46 | 46 |
| 47 Iterable map(f(String element)) => readClasses().map(f); |
| 48 |
47 Iterable mappedBy(f(String element)) => readClasses().mappedBy(f); | 49 Iterable mappedBy(f(String element)) => readClasses().mappedBy(f); |
48 | 50 |
49 Iterable<String> where(bool f(String element)) => readClasses().where(f); | 51 Iterable<String> where(bool f(String element)) => readClasses().where(f); |
50 | 52 |
51 bool every(bool f(String element)) => readClasses().every(f); | 53 bool every(bool f(String element)) => readClasses().every(f); |
52 | 54 |
53 bool any(bool f(String element)) => readClasses().any(f); | 55 bool any(bool f(String element)) => readClasses().any(f); |
54 | 56 |
55 bool get isEmpty => readClasses().isEmpty; | 57 bool get isEmpty => readClasses().isEmpty; |
56 | 58 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 136 |
135 void clear() { | 137 void clear() { |
136 _modify((s) => s.clear()); | 138 _modify((s) => s.clear()); |
137 } | 139 } |
138 // interface Set - END | 140 // interface Set - END |
139 | 141 |
140 /** | 142 /** |
141 * Helper method used to modify the set of css classes on this element. | 143 * Helper method used to modify the set of css classes on this element. |
142 * | 144 * |
143 * f - callback with: | 145 * f - callback with: |
144 * s - a Set of all the css class name currently on this element. | 146 * s - a Set of all the css class name currently on this element. |
145 * | 147 * |
146 * After f returns, the modified set is written to the | 148 * After f returns, the modified set is written to the |
147 * className property of this element. | 149 * className property of this element. |
148 */ | 150 */ |
149 void _modify( f(Set<String> s)) { | 151 void _modify( f(Set<String> s)) { |
150 Set<String> s = readClasses(); | 152 Set<String> s = readClasses(); |
151 f(s); | 153 f(s); |
152 writeClasses(s); | 154 writeClasses(s); |
153 } | 155 } |
154 | 156 |
155 /** | 157 /** |
156 * Read the class names from the Element class property, | 158 * Read the class names from the Element class property, |
157 * and put them into a set (duplicates are discarded). | 159 * and put them into a set (duplicates are discarded). |
158 * This is intended to be overridden by specific implementations. | 160 * This is intended to be overridden by specific implementations. |
159 */ | 161 */ |
160 Set<String> readClasses(); | 162 Set<String> readClasses(); |
161 | 163 |
162 /** | 164 /** |
163 * Join all the elements of a set into one string and write | 165 * Join all the elements of a set into one string and write |
164 * back to the element. | 166 * back to the element. |
165 * This is intended to be overridden by specific implementations. | 167 * This is intended to be overridden by specific implementations. |
166 */ | 168 */ |
167 void writeClasses(Set<String> s); | 169 void writeClasses(Set<String> s); |
168 } | 170 } |
OLD | NEW |