traverse()

in packages/svg-mixer/lib/transformations/move-nodes-outside-symbol.js [22:41]


    traverse(tree).forEach(function (node) {
      if (!this.isLeaf && node.tag && node.tag === 'symbol') {
        const symbol = this.parent.node;
        const nodesToRemove = [];

        traverse(node.content).forEach(function (n) {
          if (!this.isLeaf && n.tag && cfg.tags.indexOf(n.tag) !== -1) {
            const parent = this.parent.node;
            const cloned = clone(this.node);
            symbol.push(cloned);
            nodesToRemove.push({ parent, node: n });
          }
        });

        nodesToRemove.forEach(item => {
          const nodeIndex = item.parent.indexOf(item.node);
          item.parent.splice(nodeIndex, 1);
        });
      }
    });