| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class _ChildrenNodeList implements NodeList { | 5 class _ChildrenNodeList implements NodeList { |
| 6 // Raw node. | 6 // Raw node. |
| 7 final _node; | 7 final _node; |
| 8 final _childNodes; | 8 final _childNodes; |
| 9 | 9 |
| 10 _ChildrenNodeList._wrap(var node) | 10 _ChildrenNodeList._wrap(var node) |
| 11 : _childNodes = node.childNodes, | 11 : _childNodes = node.childNodes, |
| 12 _node = node; | 12 _node = node; |
| 13 | 13 |
| 14 List<Node> _toList() { | 14 List<Node> _toList() { |
| 15 final output = new List(_childNodes.length); | 15 final output = new List(_childNodes.length); |
| 16 for (int i = 0, len = _childNodes.length; i < len; i++) { | 16 for (int i = 0, len = _childNodes.length; i < len; i++) { |
| 17 output[i] = LevelDom.wrapNode(_childNodes[i]); | 17 output[i] = LevelDom.wrapNode(_childNodes[i]); |
| 18 } | 18 } |
| 19 return output; | 19 return output; |
| 20 } | 20 } |
| 21 | 21 |
| 22 Node get first() { | 22 Node get first() { |
| 23 return LevelDom.wrapNode(_node.firstChild); | 23 return LevelDom.wrapNode(_node.firstChild); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void forEach(void f(Node element)) => _toList().forEach(f); | 26 void forEach(void f(Node element)) => _toList().forEach(f); |
| 27 | 27 |
| 28 Collection map(f(Node element)) { |
| 29 List output = new List(); |
| 30 forEach((Node element) { |
| 31 output.add(f(element)); |
| 32 }); |
| 33 return output; |
| 34 } |
| 35 |
| 28 Collection<Node> filter(bool f(Node element)) { | 36 Collection<Node> filter(bool f(Node element)) { |
| 29 List<Node> output = new List<Node>(); | 37 List<Node> output = new List<Node>(); |
| 30 forEach((Node element) { | 38 forEach((Node element) { |
| 31 if (f(element)) { | 39 if (f(element)) { |
| 32 output.add(element); | 40 output.add(element); |
| 33 } | 41 } |
| 34 }); | 42 }); |
| 35 return output; | 43 return output; |
| 36 } | 44 } |
| 37 | 45 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // array. | 216 // array. |
| 209 Node insertBefore(Node newChild, Node refChild) { | 217 Node insertBefore(Node newChild, Node refChild) { |
| 210 return LevelDom.wrapNode(_ptr.insertBefore( | 218 return LevelDom.wrapNode(_ptr.insertBefore( |
| 211 LevelDom.unwrap(newChild), LevelDom.unwrap(refChild))); | 219 LevelDom.unwrap(newChild), LevelDom.unwrap(refChild))); |
| 212 } | 220 } |
| 213 | 221 |
| 214 Node clone(bool deep) { | 222 Node clone(bool deep) { |
| 215 return LevelDom.wrapNode(_ptr.cloneNode(deep)); | 223 return LevelDom.wrapNode(_ptr.cloneNode(deep)); |
| 216 } | 224 } |
| 217 } | 225 } |
| OLD | NEW |