Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: sdk/lib/html/html_common/css_class_set.dart

Issue 26832002: Add Set.lookup method to get the instance in the set. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/corelib/hash_set_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/corelib/hash_set_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698