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

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

Issue 12596004: Replaced Element.append with Node.appendChild (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
8 // functionality. 8 // functionality.
9 class _ChildrenElementList implements List { 9 class _ChildrenElementList implements List {
10 // Raw Element. 10 // Raw Element.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void operator []=(int index, Element value) { 126 void operator []=(int index, Element value) {
127 _element.$dom_replaceChild(value, _childElements[index]); 127 _element.$dom_replaceChild(value, _childElements[index]);
128 } 128 }
129 129
130 void set length(int newLength) { 130 void set length(int newLength) {
131 // TODO(jacobr): remove children when length is reduced. 131 // TODO(jacobr): remove children when length is reduced.
132 throw new UnsupportedError(''); 132 throw new UnsupportedError('');
133 } 133 }
134 134
135 Element add(Element value) { 135 Element add(Element value) {
136 _element.$dom_appendChild(value); 136 _element.append(value);
137 return value; 137 return value;
138 } 138 }
139 139
140 Element addLast(Element value) => add(value); 140 Element addLast(Element value) => add(value);
141 141
142 Iterator<Element> get iterator => toList().iterator; 142 Iterator<Element> get iterator => toList().iterator;
143 143
144 void addAll(Iterable<Element> iterable) { 144 void addAll(Iterable<Element> iterable) {
145 if (iterable is _ChildNodeListLazy) { 145 if (iterable is _ChildNodeListLazy) {
146 iterable = new List.from(iterable); 146 iterable = new List.from(iterable);
147 } 147 }
148 148
149 for (Element element in iterable) { 149 for (Element element in iterable) {
150 _element.$dom_appendChild(element); 150 _element.append(element);
151 } 151 }
152 } 152 }
153 153
154 Iterable<Element> get reversed { 154 Iterable<Element> get reversed {
155 return IterableMixinWorkaround.reversedList(this); 155 return IterableMixinWorkaround.reversedList(this);
156 } 156 }
157 157
158 void sort([int compare(Element a, Element b)]) { 158 void sort([int compare(Element a, Element b)]) {
159 throw new UnsupportedError('TODO(jacobr): should we impl?'); 159 throw new UnsupportedError('TODO(jacobr): should we impl?');
160 } 160 }
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 int get offsetWidth => offset.width; 757 int get offsetWidth => offset.width;
758 758
759 @DomName('Element.offsetHeight') 759 @DomName('Element.offsetHeight')
760 @DomName('Element.offsetLeft') 760 @DomName('Element.offsetLeft')
761 @DomName('Element.offsetTop') 761 @DomName('Element.offsetTop')
762 @DomName('Element.offsetWidth') 762 @DomName('Element.offsetWidth')
763 Rect get offset => new Rect($dom_offsetLeft, $dom_offsetTop, $dom_offsetWidth, 763 Rect get offset => new Rect($dom_offsetLeft, $dom_offsetTop, $dom_offsetWidth,
764 $dom_offsetHeight); 764 $dom_offsetHeight);
765 765
766 /** 766 /**
767 * Adds the specified element to after the last child of this element.
768 */
769 void append(Element e) {
770 this.children.add(e);
771 }
772
773 /**
774 * Adds the specified text as a text node after the last child of this 767 * Adds the specified text as a text node after the last child of this
775 * element. 768 * element.
776 */ 769 */
777 void appendText(String text) { 770 void appendText(String text) {
778 this.insertAdjacentText('beforeend', text); 771 this.insertAdjacentText('beforeend', text);
779 } 772 }
780 773
781 /** 774 /**
782 * Parses the specified text as HTML and adds the resulting node after the 775 * Parses the specified text as HTML and adds the resulting node after the
783 * last child of this element. 776 * last child of this element.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 void _insertAdjacentNode(String where, Node node) { 961 void _insertAdjacentNode(String where, Node node) {
969 switch (where.toLowerCase()) { 962 switch (where.toLowerCase()) {
970 case 'beforebegin': 963 case 'beforebegin':
971 this.parentNode.insertBefore(node, this); 964 this.parentNode.insertBefore(node, this);
972 break; 965 break;
973 case 'afterbegin': 966 case 'afterbegin':
974 var first = this.nodes.length > 0 ? this.nodes[0] : null; 967 var first = this.nodes.length > 0 ? this.nodes[0] : null;
975 this.insertBefore(node, first); 968 this.insertBefore(node, first);
976 break; 969 break;
977 case 'beforeend': 970 case 'beforeend':
978 this.nodes.add(node); 971 this.append(node);
979 break; 972 break;
980 case 'afterend': 973 case 'afterend':
981 this.parentNode.insertBefore(node, this.nextNode); 974 this.parentNode.insertBefore(node, this.nextNode);
982 break; 975 break;
983 default: 976 default:
984 throw new ArgumentError("Invalid position ${where}"); 977 throw new ArgumentError("Invalid position ${where}");
985 } 978 }
986 } 979 }
987 980
988 /** 981 /**
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 const ScrollAlignment._internal(this._value); 1149 const ScrollAlignment._internal(this._value);
1157 toString() => 'ScrollAlignment.$_value'; 1150 toString() => 'ScrollAlignment.$_value';
1158 1151
1159 /// Attempt to align the element to the top of the scrollable area. 1152 /// Attempt to align the element to the top of the scrollable area.
1160 static const TOP = const ScrollAlignment._internal('TOP'); 1153 static const TOP = const ScrollAlignment._internal('TOP');
1161 /// Attempt to center the element in the scrollable area. 1154 /// Attempt to center the element in the scrollable area.
1162 static const CENTER = const ScrollAlignment._internal('CENTER'); 1155 static const CENTER = const ScrollAlignment._internal('CENTER');
1163 /// Attempt to align the element to the bottom of the scrollable area. 1156 /// Attempt to align the element to the bottom of the scrollable area.
1164 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1157 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1165 } 1158 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate ('k') | tools/dom/templates/html/impl/impl_Node.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698