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

Side by Side Diff: lib/dom/templates/html/impl/impl_Element.darttemplate

Issue 10222026: Migrate dom tests to dart:html. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 5 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
6 // functionality. 6 // functionality.
7 class _ChildrenElementList implements ElementList { 7 class _ChildrenElementList implements ElementList {
8 // Raw Element. 8 // Raw Element.
9 final _ElementImpl _element; 9 final _ElementImpl _element;
10 final _HTMLCollectionImpl _childElements; 10 final _HTMLCollectionImpl _childElements;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 String operator [](String key) { 328 String operator [](String key) {
329 return _element.$dom_getAttribute(key); 329 return _element.$dom_getAttribute(key);
330 } 330 }
331 331
332 void operator []=(String key, value) { 332 void operator []=(String key, value) {
333 _element.$dom_setAttribute(key, '$value'); 333 _element.$dom_setAttribute(key, '$value');
334 } 334 }
335 335
336 String putIfAbsent(String key, String ifAbsent()) { 336 String putIfAbsent(String key, String ifAbsent()) {
337 if (!containsKey(key)) { 337 if (!containsKey(key)) {
Anton Muhin 2012/04/26 18:47:36 technically you can use Maps.putIfAbsent here as y
338 this[key] = ifAbsent(); 338 this[key] = ifAbsent();
339 } 339 }
340 return this[key];
340 } 341 }
341 342
342 String remove(String key) { 343 String remove(String key) {
344 String value = _element.$dom_getAttribute(key);
343 _element.$dom_removeAttribute(key); 345 _element.$dom_removeAttribute(key);
346 return value;
344 } 347 }
345 348
346 void clear() { 349 void clear() {
347 final attributes = _element.$dom_attributes; 350 final attributes = _element.$dom_attributes;
348 for (int i = attributes.length - 1; i >= 0; i--) { 351 for (int i = attributes.length - 1; i >= 0; i--) {
349 remove(attributes[i].name); 352 remove(attributes[i].name);
350 } 353 }
351 } 354 }
352 355
353 void forEach(void f(String key, String value)) { 356 void forEach(void f(String key, String value)) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 bool containsValue(String value) => getValues().some((v) => v == value); 412 bool containsValue(String value) => getValues().some((v) => v == value);
410 413
411 bool containsKey(String key) => $dom_attributes.containsKey(_attr(key)); 414 bool containsKey(String key) => $dom_attributes.containsKey(_attr(key));
412 415
413 String operator [](String key) => $dom_attributes[_attr(key)]; 416 String operator [](String key) => $dom_attributes[_attr(key)];
414 417
415 void operator []=(String key, value) { 418 void operator []=(String key, value) {
416 $dom_attributes[_attr(key)] = '$value'; 419 $dom_attributes[_attr(key)] = '$value';
417 } 420 }
418 421
419 String putIfAbsent(String key, String ifAbsent()) { 422 String putIfAbsent(String key, String ifAbsent()) =>
420 $dom_attributes.putIfAbsent(_attr(key), ifAbsent); 423 $dom_attributes.putIfAbsent(_attr(key), ifAbsent);
421 }
422 424
423 String remove(String key) => $dom_attributes.remove(_attr(key)); 425 String remove(String key) => $dom_attributes.remove(_attr(key));
424 426
425 void clear() { 427 void clear() {
426 // Needs to operate on a snapshot since we are mutating the collection. 428 // Needs to operate on a snapshot since we are mutating the collection.
427 for (String key in getKeys()) { 429 for (String key in getKeys()) {
428 remove(key); 430 remove(key);
429 } 431 }
430 } 432 }
431 433
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 774
773 /** @domName Document.createElement */ 775 /** @domName Document.createElement */
774 $if FROG 776 $if FROG
775 // Optimization to improve performance until the frog compiler inlines this 777 // Optimization to improve performance until the frog compiler inlines this
776 // method. 778 // method.
777 factory Element.tag(String tag) native "return document.createElement(tag)"; 779 factory Element.tag(String tag) native "return document.createElement(tag)";
778 $else 780 $else
779 factory Element.tag(String tag) => _document.$dom_createElement(tag); 781 factory Element.tag(String tag) => _document.$dom_createElement(tag);
780 $endif 782 $endif
781 } 783 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698