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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 bool isSubsetOf(Collection<String> collection) => | 90 bool isSubsetOf(Collection<String> collection) => |
91 readClasses().isSubsetOf(collection); | 91 readClasses().isSubsetOf(collection); |
92 | 92 |
93 bool containsAll(Collection<String> collection) => | 93 bool containsAll(Collection<String> collection) => |
94 readClasses().containsAll(collection); | 94 readClasses().containsAll(collection); |
95 | 95 |
96 Set<String> intersection(Collection<String> other) => | 96 Set<String> intersection(Collection<String> other) => |
97 readClasses().intersection(other); | 97 readClasses().intersection(other); |
98 | 98 |
| 99 String get first => readClasses().first; |
| 100 String get last => readClasses().last; |
| 101 String get single => readClasses().single; |
| 102 List<String> toList() => readClasses().toList(); |
| 103 Set<String> toSet() => readClasses().toSet(); |
| 104 String min([int compare(String a, String b)]) => |
| 105 readClasses().min(compare); |
| 106 String max([int compare(String a, String b)]) => |
| 107 readClasses().max(compare); |
| 108 Iterable<String> take(int n) => readClasses().take(n); |
| 109 Iterable<String> takeWhile(bool test(String value)) => |
| 110 readClasses().takeWhile(test); |
| 111 Iterable<String> skip(int n) => readClasses().skip(n); |
| 112 Iterable<String> skipWhile(bool test(String value)) => |
| 113 readClasses().skipWhile(test); |
| 114 String firstMatching(bool test(String value), { String orElse() }) => |
| 115 readClasses().firstMatching(test, orElse: orElse); |
| 116 String lastMatching(bool test(String value), {String orElse()}) => |
| 117 readClasses().lastMatching(test, orElse: orElse); |
| 118 String singleMatching(bool test(String value)) => |
| 119 readClasses().singleMatching(test); |
| 120 String elementAt(int index) => readClasses().elementAt(index); |
| 121 |
99 void clear() { | 122 void clear() { |
100 _modify((s) => s.clear()); | 123 _modify((s) => s.clear()); |
101 } | 124 } |
102 // interface Set - END | 125 // interface Set - END |
103 | 126 |
104 /** | 127 /** |
105 * Helper method used to modify the set of css classes on this element. | 128 * Helper method used to modify the set of css classes on this element. |
106 * | 129 * |
107 * f - callback with: | 130 * f - callback with: |
108 * s - a Set of all the css class name currently on this element. | 131 * s - a Set of all the css class name currently on this element. |
(...skipping 14 matching lines...) Expand all Loading... |
123 */ | 146 */ |
124 Set<String> readClasses(); | 147 Set<String> readClasses(); |
125 | 148 |
126 /** | 149 /** |
127 * Join all the elements of a set into one string and write | 150 * Join all the elements of a set into one string and write |
128 * back to the element. | 151 * back to the element. |
129 * This is intended to be overridden by specific implementations. | 152 * This is intended to be overridden by specific implementations. |
130 */ | 153 */ |
131 void writeClasses(Set<String> s); | 154 void writeClasses(Set<String> s); |
132 } | 155 } |
OLD | NEW |