* @function LevelRenderer.Group.prototype.traverse * @description 深度优先遍历所有子孙节点。 * @param {function} cb - 回调函数。 * @param {Object} context - 上下文。
(cb, context)
| 201 | * @param {Object} context - 上下文。 |
| 202 | */ |
| 203 | traverse(cb, context) { |
| 204 | var haveContext = !!context; |
| 205 | for (var i = 0; i < this._children.length; i++) { |
| 206 | var child = this._children[i]; |
| 207 | if (haveContext) { |
| 208 | cb.call(context, child); |
| 209 | } else { |
| 210 | cb(child); |
| 211 | } |
| 212 | |
| 213 | if (child.type === 'group') { |
| 214 | child.traverse(cb, context); |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | |
| 220 | /** |
no test coverage detected