OLD | NEW |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 /** | 80 /** |
81 * Returns true if there is at least one {key, value} pair in the map. | 81 * Returns true if there is at least one {key, value} pair in the map. |
82 */ | 82 */ |
83 bool get isNotEmpty => !isEmpty; | 83 bool get isNotEmpty => !isEmpty; |
84 | 84 |
85 /** | 85 /** |
86 * Checks to see if the node should be included in this map. | 86 * Checks to see if the node should be included in this map. |
87 */ | 87 */ |
88 bool _matches(Node node); | 88 bool _matches(_Attr node); |
89 } | 89 } |
90 | 90 |
91 /** | 91 /** |
92 * Wrapper to expose [Element.attributes] as a typed map. | 92 * Wrapper to expose [Element.attributes] as a typed map. |
93 */ | 93 */ |
94 class _ElementAttributeMap extends _AttributeMap { | 94 class _ElementAttributeMap extends _AttributeMap { |
95 _ElementAttributeMap(Element element) : super(element); | 95 _ElementAttributeMap(Element element) : super(element); |
96 | 96 |
97 bool containsKey(Object key) { | 97 bool containsKey(Object key) { |
98 return _element._hasAttribute(key); | 98 return _element._hasAttribute(key); |
(...skipping 13 matching lines...) Expand all Loading... |
112 return value; | 112 return value; |
113 } | 113 } |
114 | 114 |
115 /** | 115 /** |
116 * The number of {key, value} pairs in the map. | 116 * The number of {key, value} pairs in the map. |
117 */ | 117 */ |
118 int get length { | 118 int get length { |
119 return keys.length; | 119 return keys.length; |
120 } | 120 } |
121 | 121 |
122 bool _matches(Node node) => node._namespaceUri == null; | 122 bool _matches(_Attr node) => node._namespaceUri == null; |
123 } | 123 } |
124 | 124 |
125 /** | 125 /** |
126 * Wrapper to expose namespaced attributes as a typed map. | 126 * Wrapper to expose namespaced attributes as a typed map. |
127 */ | 127 */ |
128 class _NamespacedAttributeMap extends _AttributeMap { | 128 class _NamespacedAttributeMap extends _AttributeMap { |
129 final String _namespace; | 129 final String _namespace; |
130 | 130 |
131 _NamespacedAttributeMap(Element element, this._namespace) : super(element); | 131 _NamespacedAttributeMap(Element element, this._namespace) : super(element); |
132 | 132 |
(...skipping 15 matching lines...) Expand all Loading... |
148 return value; | 148 return value; |
149 } | 149 } |
150 | 150 |
151 /** | 151 /** |
152 * The number of {key, value} pairs in the map. | 152 * The number of {key, value} pairs in the map. |
153 */ | 153 */ |
154 int get length { | 154 int get length { |
155 return keys.length; | 155 return keys.length; |
156 } | 156 } |
157 | 157 |
158 bool _matches(Node node) => node._namespaceUri == _namespace; | 158 bool _matches(_Attr node) => node._namespaceUri == _namespace; |
159 } | 159 } |
160 | 160 |
161 /** | 161 /** |
162 * Provides a Map abstraction on top of data-* attributes, similar to the | 162 * Provides a Map abstraction on top of data-* attributes, similar to the |
163 * dataSet in the old DOM. | 163 * dataSet in the old DOM. |
164 */ | 164 */ |
165 class _DataAttributeMap implements Map<String, String> { | 165 class _DataAttributeMap implements Map<String, String> { |
166 final Map<String, String> _attributes; | 166 final Map<String, String> _attributes; |
167 | 167 |
168 _DataAttributeMap(this._attributes); | 168 _DataAttributeMap(this._attributes); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 String _toHyphenedName(String word) { | 260 String _toHyphenedName(String word) { |
261 var sb = new StringBuffer(); | 261 var sb = new StringBuffer(); |
262 for (int i = 0; i < word.length; i++) { | 262 for (int i = 0; i < word.length; i++) { |
263 var lower = word[i].toLowerCase(); | 263 var lower = word[i].toLowerCase(); |
264 if (word[i] != lower && i > 0) sb.write('-'); | 264 if (word[i] != lower && i > 0) sb.write('-'); |
265 sb.write(lower); | 265 sb.write(lower); |
266 } | 266 } |
267 return sb.toString(); | 267 return sb.toString(); |
268 } | 268 } |
269 } | 269 } |
OLD | NEW |