mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Revert "Add Element data property"
This reverts commit r71. git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@74 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
515c527ecd
commit
57051017bd
|
@ -549,7 +549,6 @@
|
|||
#source('src/BodyElement.dart');
|
||||
#source('src/BodyElementWrappingImplementation.dart');
|
||||
#source('src/CssClassSet.dart');
|
||||
#source('src/DataMap.dart');
|
||||
#source('src/DocumentFragment.dart');
|
||||
#source('src/DocumentFragmentWrappingImplementation.dart');
|
||||
#source('src/DocumentWrappingImplementation.dart');
|
||||
|
|
|
@ -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 _DataMap implements Map<String, String> {
|
||||
|
||||
final Map<String, String> _attributes;
|
||||
|
||||
_DataMap(this._attributes);
|
||||
|
||||
// interface Map
|
||||
|
||||
// TODO: Use lazy iterator when it is available on Map.
|
||||
bool containsValue(String value) => getValues().indexOf(value) != -1;
|
||||
|
||||
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.substringToEnd(5);
|
||||
}
|
||||
|
|
@ -84,9 +84,6 @@ interface Element extends Node /*, common.NodeSelector, common.ElementTraversal
|
|||
// TODO: The type of value should be Collection<String>. See http://b/5392897
|
||||
void set classes(value);
|
||||
|
||||
Map<String, String> get data();
|
||||
void set data(Map<String, String> value);
|
||||
|
||||
int get clientHeight();
|
||||
|
||||
int get clientLeft();
|
||||
|
|
|
@ -402,7 +402,6 @@ class ElementWrappingImplementation extends NodeWrappingImplementation implement
|
|||
ElementWrappingImplementation._wrap(ptr) : super._wrap(ptr);
|
||||
|
||||
_CssClassSet _cssClassSet;
|
||||
_DataMap _data;
|
||||
|
||||
Map<String, String> get attributes() {
|
||||
return new ElementAttributeMap._wrap(_ptr);
|
||||
|
@ -423,21 +422,6 @@ class ElementWrappingImplementation extends NodeWrappingImplementation implement
|
|||
classSet.addAll(value);
|
||||
}
|
||||
|
||||
Map<String, String> get data() {
|
||||
if (_data === null) {
|
||||
_data = new _DataMap(attributes);
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
|
||||
void set data(Map<String, String> value) {
|
||||
Map<String, String> data = this.data;
|
||||
data.clear();
|
||||
for (String key in value.getKeys()) {
|
||||
data[key] = value[key];
|
||||
}
|
||||
}
|
||||
|
||||
int get clientHeight() => _ptr.clientHeight;
|
||||
|
||||
int get clientLeft() => _ptr.clientLeft;
|
||||
|
|
Loading…
Reference in a new issue