OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function TestSupport() {}; | 5 function TestSupport() {} |
6 | 6 |
7 TestSupport.prototype = { | 7 TestSupport.prototype = { |
8 /** | 8 /** |
9 * Connect |parent| and |children| to each other. | 9 * Connect |parent| and |children| to each other. |
10 * | 10 * |
11 * @param {!Object} parent | 11 * @param {!Object} parent |
12 * @param {Array<Object>} children | 12 * @param {Array<Object>} children |
13 */ | 13 */ |
14 setChildren: function(parent, children) { | 14 setChildren: function(parent, children) { |
15 // Connect parent to its children. | 15 // Connect parent to its children. |
16 parent.children = children; | 16 parent.children = children; |
17 parent.firstChild = children[0]; | 17 parent.firstChild = children[0]; |
18 parent.lastChild = children[children.length - 1]; | 18 parent.lastChild = children[children.length - 1]; |
19 | 19 |
20 for (let i = 0; i < children.length; i++) { | 20 for (let i = 0; i < children.length; i++) { |
21 let child = children[i]; | 21 let child = children[i]; |
22 | 22 |
23 // Connect children to their parent. | 23 // Connect children to their parent. |
24 child.parent = parent; | 24 child.parent = parent; |
25 | 25 |
26 // Connect children to each other | 26 // Connect children to each other |
27 if (i < children.length - 1) | 27 if (i < children.length - 1) |
28 child.nextSibling = children[i + 1]; | 28 child.nextSibling = children[i + 1]; |
29 if (i > 0) | 29 if (i > 0) |
30 child.previousSibling = children[i - 1]; | 30 child.previousSibling = children[i - 1]; |
31 } | 31 } |
32 }, | 32 }, |
33 }; | 33 }; |
OLD | NEW |