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 /** | 5 /** |
6 * Lazy implementation of the child nodes of an element that does not request | 6 * Lazy implementation of the child nodes of an element that does not request |
7 * the actual child nodes of an element until strictly necessary greatly | 7 * the actual child nodes of an element until strictly necessary greatly |
8 * improving performance for the typical cases where it is not required. | 8 * improving performance for the typical cases where it is not required. |
9 */ | 9 */ |
10 class _ChildNodeListLazy implements List { | 10 class _ChildNodeListLazy implements List { |
11 final _NodeImpl _this; | 11 final _NodeImpl _this; |
12 | 12 |
13 _ChildNodeListLazy(this._this); | 13 _ChildNodeListLazy(this._this); |
14 | 14 |
15 | 15 |
16 $if DART2JS | 16 $if DART2JS |
17 _NodeImpl get first => JS('_NodeImpl', '#.firstChild', _this); | 17 _NodeImpl get first => JS('_NodeImpl', '#.firstChild', _this); |
18 _NodeImpl last() => JS('_NodeImpl', '#.lastChild', _this); | 18 _NodeImpl get last => JS('_NodeImpl', '#.lastChild', _this); |
19 $else | 19 $else |
20 _NodeImpl get first => _this.$dom_firstChild; | 20 _NodeImpl get first => _this.$dom_firstChild; |
21 _NodeImpl last() => _this.$dom_lastChild; | 21 _NodeImpl get last => _this.$dom_lastChild; |
22 $endif | 22 $endif |
23 | 23 |
24 void add(_NodeImpl value) { | 24 void add(_NodeImpl value) { |
25 _this.$dom_appendChild(value); | 25 _this.$dom_appendChild(value); |
26 } | 26 } |
27 | 27 |
28 void addLast(_NodeImpl value) { | 28 void addLast(_NodeImpl value) { |
29 _this.$dom_appendChild(value); | 29 _this.$dom_appendChild(value); |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 void addAll(Collection<_NodeImpl> collection) { | 33 void addAll(Collection<_NodeImpl> collection) { |
34 for (_NodeImpl node in collection) { | 34 for (_NodeImpl node in collection) { |
35 _this.$dom_appendChild(node); | 35 _this.$dom_appendChild(node); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 _NodeImpl removeLast() { | 39 _NodeImpl removeLast() { |
40 final result = last(); | 40 final result = last; |
41 if (result != null) { | 41 if (result != null) { |
42 _this.$dom_removeChild(result); | 42 _this.$dom_removeChild(result); |
43 } | 43 } |
44 return result; | 44 return result; |
45 } | 45 } |
46 | 46 |
47 void clear() { | 47 void clear() { |
48 _this.text = ''; | 48 _this.text = ''; |
49 } | 49 } |
50 | 50 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 final _NodeImpl parent = this.parent; | 139 final _NodeImpl parent = this.parent; |
140 parent.$dom_replaceChild(otherNode, this); | 140 parent.$dom_replaceChild(otherNode, this); |
141 } catch (e) { | 141 } catch (e) { |
142 | 142 |
143 }; | 143 }; |
144 return this; | 144 return this; |
145 } | 145 } |
146 | 146 |
147 $!MEMBERS | 147 $!MEMBERS |
148 } | 148 } |
OLD | NEW |