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

Side by Side Diff: tools/dom/src/AttributeMap.dart

Issue 23534024: createRange.... (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
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; 5 part of html;
6 6
7 abstract class _AttributeMap implements Map<String, String> { 7 abstract class _AttributeMap implements Map<String, String> {
8 final Element _element; 8 final Element _element;
9 9
10 _AttributeMap(this._element); 10 _AttributeMap(this._element);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 */ 85 */
86 class _ElementAttributeMap extends _AttributeMap { 86 class _ElementAttributeMap extends _AttributeMap {
87 87
88 _ElementAttributeMap(Element element): super(element); 88 _ElementAttributeMap(Element element): super(element);
89 89
90 bool containsKey(String key) { 90 bool containsKey(String key) {
91 return _element._hasAttribute(key); 91 return _element._hasAttribute(key);
92 } 92 }
93 93
94 String operator [](String key) { 94 String operator [](String key) {
95 return _element.$dom_getAttribute(key); 95 return _element._getAttribute(key);
96 } 96 }
97 97
98 void operator []=(String key, String value) { 98 void operator []=(String key, String value) {
99 _element.$dom_setAttribute(key, value); 99 _element._setAttribute(key, value);
100 } 100 }
101 101
102 String remove(String key) { 102 String remove(String key) {
103 String value = _element.$dom_getAttribute(key); 103 String value = _element._getAttribute(key);
104 _element._removeAttribute(key); 104 _element._removeAttribute(key);
105 return value; 105 return value;
106 } 106 }
107 107
108 /** 108 /**
109 * The number of {key, value} pairs in the map. 109 * The number of {key, value} pairs in the map.
110 */ 110 */
111 int get length { 111 int get length {
112 return keys.length; 112 return keys.length;
113 } 113 }
114 114
115 bool _matches(Node node) => node._namespaceUri == null; 115 bool _matches(Node node) => node._namespaceUri == null;
116 } 116 }
117 117
118 /** 118 /**
119 * Wrapper to expose namespaced attributes as a typed map. 119 * Wrapper to expose namespaced attributes as a typed map.
120 */ 120 */
121 class _NamespacedAttributeMap extends _AttributeMap { 121 class _NamespacedAttributeMap extends _AttributeMap {
122 122
123 final String _namespace; 123 final String _namespace;
124 124
125 _NamespacedAttributeMap(Element element, this._namespace): super(element); 125 _NamespacedAttributeMap(Element element, this._namespace): super(element);
126 126
127 bool containsKey(String key) { 127 bool containsKey(String key) {
128 return _element._hasAttributeNS(_namespace, key); 128 return _element._hasAttributeNS(_namespace, key);
129 } 129 }
130 130
131 String operator [](String key) { 131 String operator [](String key) {
132 return _element.$dom_getAttributeNS(_namespace, key); 132 return _element._getAttributeNS(_namespace, key);
133 } 133 }
134 134
135 void operator []=(String key, String value) { 135 void operator []=(String key, String value) {
136 _element.$dom_setAttributeNS(_namespace, key, value); 136 _element._setAttributeNS(_namespace, key, value);
137 } 137 }
138 138
139 String remove(String key) { 139 String remove(String key) {
140 String value = this[key]; 140 String value = this[key];
141 _element._removeAttributeNS(_namespace, key); 141 _element._removeAttributeNS(_namespace, key);
142 return value; 142 return value;
143 } 143 }
144 144
145 /** 145 /**
146 * The number of {key, value} pairs in the map. 146 * The number of {key, value} pairs in the map.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // TODO: Use lazy iterator when it is available on Map. 221 // TODO: Use lazy iterator when it is available on Map.
222 bool get isEmpty => length == 0; 222 bool get isEmpty => length == 0;
223 223
224 bool get isNotEmpty => !isEmpty; 224 bool get isNotEmpty => !isEmpty;
225 225
226 // Helpers. 226 // Helpers.
227 String _attr(String key) => 'data-$key'; 227 String _attr(String key) => 'data-$key';
228 bool _matches(String key) => key.startsWith('data-'); 228 bool _matches(String key) => key.startsWith('data-');
229 String _strip(String key) => key.substring(5); 229 String _strip(String key) => key.substring(5);
230 } 230 }
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698