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

Unified Diff: lib/dom/templates/html/impl/impl_Element.darttemplate

Issue 10868026: Adding .toggle method to Element.classes to match the JS element.classList.toggle method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding CSSClassSet to wrappers and converting it to a frozen API on DocumentFragment. Created 8 years, 4 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
Index: lib/dom/templates/html/impl/impl_Element.darttemplate
diff --git a/lib/dom/templates/html/impl/impl_Element.darttemplate b/lib/dom/templates/html/impl/impl_Element.darttemplate
index fc2842d02aec158e2ee99ab902f5c8115768eec6..57424f778d1384f4a0a06924e681444c518ee379 100644
--- a/lib/dom/templates/html/impl/impl_Element.darttemplate
+++ b/lib/dom/templates/html/impl/impl_Element.darttemplate
@@ -470,7 +470,7 @@ class _DataAttributeMap implements AttributeMap {
String _strip(String key) => key.substring(5);
}
-class _CssClassSet implements Set<String> {
+class _CssClassSet implements CSSClassSet {
final _ElementImpl _element;
@@ -497,6 +497,8 @@ class _CssClassSet implements Set<String> {
bool isEmpty() => _read().isEmpty();
+ bool isFrozen() => false;
+
int get length() =>_read().length;
// interface Collection - END
@@ -517,6 +519,19 @@ class _CssClassSet implements Set<String> {
return result;
}
+ bool toggle(String value) {
+ Set<String> s = _read();
+ bool result = false;
+ if (s.contains(value)) {
+ s.remove(value);
+ } else {
+ s.add(value);
+ result = true;
+ }
+ _write(s);
+ return result;
+ }
+
void addAll(Collection<String> collection) {
// TODO - see comment above about validation
_modify((s) => s.addAll(collection));
@@ -624,14 +639,14 @@ class _ElementRectImpl implements ElementRect {
// TODO(jacobr): should we move these outside of ElementRect to avoid the
// overhead of computing them every time even though they are rarely used.
- final _ClientRectImpl _boundingClientRect;
+ final _ClientRectImpl _boundingClientRect;
final _ClientRectListImpl _clientRects;
_ElementRectImpl(_ElementImpl element) :
client = new _SimpleClientRect(element.$dom_clientLeft,
element.$dom_clientTop,
- element.$dom_clientWidth,
- element.$dom_clientHeight),
+ element.$dom_clientWidth,
+ element.$dom_clientHeight),
offset = new _SimpleClientRect(element.$dom_offsetLeft,
element.$dom_offsetTop,
element.$dom_offsetWidth,

Powered by Google App Engine
This is Rietveld 408576698