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

Unified Diff: client/html/src/DataAttributeMap.dart

Issue 9845043: Rename client/{dom,html} to lib/{dom,html} . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/html/src/CustomEventWrappingImplementation.dart ('k') | client/html/src/Device.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/html/src/DataAttributeMap.dart
===================================================================
--- client/html/src/DataAttributeMap.dart (revision 5796)
+++ client/html/src/DataAttributeMap.dart (working copy)
@@ -1,82 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/**
- * Provides a Map abstraction on top of data-* attributes, similar to the
- * dataSet in the old DOM.
- */
-class _DataAttributeMap implements Map<String, String> {
-
- final Map<String, String> _attributes;
-
- _DataAttributeMap(this._attributes);
-
- // interface Map
-
- // TODO: Use lazy iterator when it is available on Map.
- bool containsValue(String value) => getValues().some((v) => v == value);
-
- bool containsKey(String key) => _attributes.containsKey(_attr(key));
-
- String operator [](String key) => _attributes[_attr(key)];
-
- void operator []=(String key, String value) {
- _attributes[_attr(key)] = value;
- }
-
- String putIfAbsent(String key, String ifAbsent()) {
- if (!containsKey(key)) {
- return this[key] = ifAbsent();
- }
- return this[key];
- }
-
- String remove(String key) => _attributes.remove(_attr(key));
-
- void clear() {
- // Needs to operate on a snapshot since we are mutatiting the collection.
- for (String key in getKeys()) {
- remove(key);
- }
- }
-
- void forEach(void f(String key, String value)) {
- _attributes.forEach((String key, String value) {
- if (_matches(key)) {
- f(_strip(key), value);
- }
- });
- }
-
- Collection<String> getKeys() {
- final keys = new List<String>();
- _attributes.forEach((String key, String value) {
- if (_matches(key)) {
- keys.add(_strip(key));
- }
- });
- return keys;
- }
-
- Collection<String> getValues() {
- final values = new List<String>();
- _attributes.forEach((String key, String value) {
- if (_matches(key)) {
- values.add(value);
- }
- });
- return values;
- }
-
- int get length() => getKeys().length;
-
- // TODO: Use lazy iterator when it is available on Map.
- bool isEmpty() => length == 0;
-
- // Helpers.
- String _attr(String key) => 'data-$key';
- bool _matches(String key) => key.startsWith('data-');
- String _strip(String key) => key.substring(5);
-}
-
« no previous file with comments | « client/html/src/CustomEventWrappingImplementation.dart ('k') | client/html/src/Device.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698