OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 function TestSupport() {}; |
| 6 |
| 7 TestSupport.prototype = { |
| 8 /** |
| 9 * Connect |parent| and |children| to each other. |
| 10 * |
| 11 * @param {!Object} parent |
| 12 * @param {Array<Object>} children |
| 13 */ |
| 14 setChildren: function(parent, children) { |
| 15 // Connect parent to its children. |
| 16 parent.children = children; |
| 17 parent.firstChild = children[0]; |
| 18 parent.lastChild = children[children.length - 1]; |
| 19 |
| 20 for (let i = 0; i < children.length; i++) { |
| 21 let child = children[i]; |
| 22 |
| 23 // Connect children to their parent. |
| 24 child.parent = parent; |
| 25 |
| 26 // Connect children to each other |
| 27 if (i < children.length - 1) |
| 28 child.nextSibling = children[i + 1]; |
| 29 if (i > 0) |
| 30 child.previousSibling = children[i - 1]; |
| 31 } |
| 32 }, |
| 33 }; |
OLD | NEW |