node_modules/ant-design-vue/es/vc-tree/utils/treeUtil.js
/**
 * Traverse all the data by `treeData`.
 * Please not use it out of the `rc-tree` since we may refactor this code.
 */
Traverse all the data by `treeData`.
Please not use it out of the `rc-tree` since we may refactor this code.
Traverse all the data by ` treeData ` . Please not use it out of the ` rc - tree ` since we may refactor this code .
function traverseDataNodes(dataNodes, callback, 
config) {
  var mergedConfig = {};
  if (_typeof(config) === 'object') {
    mergedConfig = config;
  } else {
    mergedConfig = {
      externalGetKey: config
    };
  }
  mergedConfig = mergedConfig || {}; 
  var _mergedConfig = mergedConfig,
      childrenPropName = _mergedConfig.childrenPropName,
      externalGetKey = _mergedConfig.externalGetKey,
      fieldNames = _mergedConfig.fieldNames;
  var _fillFieldNames2 = fillFieldNames(fieldNames),
      fieldKey = _fillFieldNames2.key,
      fieldChildren = _fillFieldNames2.children;
  var mergeChildrenPropName = childrenPropName || fieldChildren; 
  var syntheticGetKey;
  if (externalGetKey) {
    if (typeof externalGetKey === 'string') {
      syntheticGetKey = function syntheticGetKey(node) {
        return node[externalGetKey];
      };
    } else if (typeof externalGetKey === 'function') {
      syntheticGetKey = function syntheticGetKey(node) {
        return externalGetKey(node);
      };
    }
  } else {
    syntheticGetKey = function syntheticGetKey(node, pos) {
      return getKey(node[fieldKey], pos);
    };
  } 
  function processNode(node, index, parent, pathNodes) {
    var children = node ? node[mergeChildrenPropName] : dataNodes;
    var pos = node ? getPosition(parent.pos, index) : '0';
    var connectNodes = node ? [].concat(_toConsumableArray(pathNodes), [node]) : [];  node if is not root
    if (node) {
      var key = syntheticGetKey(node, pos);
      var data = {
        node: node,
        index: index,
        pos: pos,
        key: key,
        parentPos: parent.node ? parent.pos : null,
        level: parent.level + 1,
        nodes: connectNodes
      };
      callback(data);
    }  children node
    if (children) {
      children.forEach(function (subNode, subIndex) {
        processNode(subNode, subIndex, {
          node: node,
          pos: pos,
          level: parent ? parent.level + 1 : -1
        }, connectNodes);
      });
    }
  }
  processNode(null);
}
function traverseDataNodes ( dataNodes , callback , config ) { var mergedConfig = { } ; if ( _typeof ( config ) === 'object' ) { mergedConfig = config ; } else { mergedConfig = { externalGetKey : config } ; } mergedConfig = mergedConfig || { } ; var _mergedConfig = mergedConfig , childrenPropName = _mergedConfig . childrenPropName , externalGetKey = _mergedConfig . externalGetKey , fieldNames = _mergedConfig . fieldNames ; var _fillFieldNames2 = fillFieldNames ( fieldNames ) , fieldKey = _fillFieldNames2 . key , fieldChildren = _fillFieldNames2 . children ; var mergeChildrenPropName = childrenPropName || fieldChildren ; var syntheticGetKey ; if ( externalGetKey ) { if ( typeof externalGetKey === 'string' ) { syntheticGetKey = function syntheticGetKey ( node ) { return node [ externalGetKey ] ; } ; } else if ( typeof externalGetKey === 'function' ) { syntheticGetKey = function syntheticGetKey ( node ) { return externalGetKey ( node ) ; } ; } } else { syntheticGetKey = function syntheticGetKey ( node , pos ) { return getKey ( node [ fieldKey ] , pos ) ; } ; } function processNode ( node , index , parent , pathNodes ) { var children = node ? node [ mergeChildrenPropName ] : dataNodes ; var pos = node ? getPosition ( parent . pos , index ) : '0' ; var connectNodes = node ? [ ] . concat ( _toConsumableArray ( pathNodes ) , [ node ] ) : [ ] ; if ( node ) { var key = syntheticGetKey ( node , pos ) ; var data = { node : node , index : index , pos : pos , key : key , parentPos : parent . node ? parent . pos : null , level : parent . level + 1 , nodes : connectNodes } ; callback ( data ) ; } if ( children ) { children . forEach ( function ( subNode , subIndex ) { processNode ( subNode , subIndex , { node : node , pos : pos , level : parent ? parent . level + 1 : - 1 } , connectNodes ) ; } ) ; } } processNode ( null ) ; }
Traverse all the data by `treeData`.
Traverse all the data by ` treeData ` .
// To avoid too many params, let use config instead of origin param // Init config // Get keys // Process // Process node if is not root // Process children node