src/basis/dom.js
function axis(root, axis, filter){
    var result = [];
    var walker;
    var cursor;

    filter = typeof filter == 'string' ? getter(filter) : filter || basis.fn.$true;

    if (axis & (AXIS_SELF | AXIS_ANCESTOR_OR_SELF | AXIS_DESCENDANT_OR_SELF))
      if (filter(root))
        result.push(root);

    switch (axis)
    {
      case AXIS_ANCESTOR:
      case AXIS_ANCESTOR_OR_SELF:
        cursor = root;
        while ((cursor = cursor[PARENT_NODE]) && cursor !== root.document)
          if (filter(cursor))
            result.push(cursor);
        break;

      case AXIS_CHILD:
        cursor = root[FIRST_CHILD];
        while (cursor)
        {
          if (filter(cursor))
            result.push(cursor);
          cursor = cursor[NEXT_SIBLING];
        }
        break;

      case AXIS_DESCENDANT:
      case AXIS_DESCENDANT_OR_SELF:
        if (root[FIRST_CHILD])
        {
          walker = new TreeWalker(root);
          walker.nodes(filter, result);
        }
        break;

      case AXIS_FOLLOWING:
        walker = new TreeWalker(root, filter);
        walker.cursor_ = root[NEXT_SIBLING] || root[PARENT_NODE];
        while (cursor = walker.next())
          result.push(cursor);
        break;

      case AXIS_FOLLOWING_SIBLING:
        cursor = root;
        while (cursor = cursor[NEXT_SIBLING])
          if (filter(cursor))
             result.push(cursor);
        break;

      case AXIS_PARENT:
        if (filter(root[PARENT_NODE]))
          result.push(root[PARENT_NODE]);
        break;

      case AXIS_PRECEDING:
        walker = new TreeWalker(root, filter, TreeWalker.BACKWARD);
        walker.cursor_ = root[PREVIOUS_SIBLING] || root[PARENT_NODE];
        while (cursor = walker.next())
          result.push(cursor);
        break;

      case AXIS_PRECEDING_SIBLING:
        cursor = root;
        while (cursor = cursor[PREVIOUS_SIBLING])
          if (filter(cursor))
            result.push(cursor);
        break;
    }

    return result;
  }
function axis(root, axis, filter){
    var result = [];
    var walker;
    var cursor;

    filter = typeof filter == 'string' ? getter(filter) : filter || basis.fn.$true;

    if (axis & (AXIS_SELF | AXIS_ANCESTOR_OR_SELF | AXIS_DESCENDANT_OR_SELF))
      if (filter(root))
        result.push(root);

    switch (axis)
    {
      case AXIS_ANCESTOR:
      case AXIS_ANCESTOR_OR_SELF:
        cursor = root;
        while ((cursor = cursor[PARENT_NODE]) && cursor !== root.document)
          if (filter(cursor))
            result.push(cursor);
        break;

      case AXIS_CHILD:
        cursor = root[FIRST_CHILD];
        while (cursor)
        {
          if (filter(cursor))
            result.push(cursor);
          cursor = cursor[NEXT_SIBLING];
        }
        break;

      case AXIS_DESCENDANT:
      case AXIS_DESCENDANT_OR_SELF:
        if (root[FIRST_CHILD])
        {
          walker = new TreeWalker(root);
          walker.nodes(filter, result);
        }
        break;

      case AXIS_FOLLOWING:
        walker = new TreeWalker(root, filter);
        walker.cursor_ = root[NEXT_SIBLING] || root[PARENT_NODE];
        while (cursor = walker.next())
          result.push(cursor);
        break;

      case AXIS_FOLLOWING_SIBLING:
        cursor = root;
        while (cursor = cursor[NEXT_SIBLING])
          if (filter(cursor))
             result.push(cursor);
        break;

      case AXIS_PARENT:
        if (filter(root[PARENT_NODE]))
          result.push(root[PARENT_NODE]);
        break;

      case AXIS_PRECEDING:
        walker = new TreeWalker(root, filter, TreeWalker.BACKWARD);
        walker.cursor_ = root[PREVIOUS_SIBLING] || root[PARENT_NODE];
        while (cursor = walker.next())
          result.push(cursor);
        break;

      case AXIS_PRECEDING_SIBLING:
        cursor = root;
        while (cursor = cursor[PREVIOUS_SIBLING])
          if (filter(cursor))
            result.push(cursor);
        break;
    }

    return result;
  }
function axis ( root , axis , filter ) { var result = [ ] ; var walker ; var cursor ; filter = typeof filter == 'string' ? getter ( filter ) : filter || basis . fn . $true ; if ( axis & ( AXIS_SELF | AXIS_ANCESTOR_OR_SELF | AXIS_DESCENDANT_OR_SELF ) ) if ( filter ( root ) ) result . push ( root ) ; switch ( axis ) { case AXIS_ANCESTOR : case AXIS_ANCESTOR_OR_SELF : cursor = root ; while ( ( cursor = cursor [ PARENT_NODE ] ) && cursor !== root . document ) if ( filter ( cursor ) ) result . push ( cursor ) ; break ; case AXIS_CHILD : cursor = root [ FIRST_CHILD ] ; while ( cursor ) { if ( filter ( cursor ) ) result . push ( cursor ) ; cursor = cursor [ NEXT_SIBLING ] ; } break ; case AXIS_DESCENDANT : case AXIS_DESCENDANT_OR_SELF : if ( root [ FIRST_CHILD ] ) { walker = new TreeWalker ( root ) ; walker . nodes ( filter , result ) ; } break ; case AXIS_FOLLOWING : walker = new TreeWalker ( root , filter ) ; walker . cursor_ = root [ NEXT_SIBLING ] || root [ PARENT_NODE ] ; while ( cursor = walker . next ( ) ) result . push ( cursor ) ; break ; case AXIS_FOLLOWING_SIBLING : cursor = root ; while ( cursor = cursor [ NEXT_SIBLING ] ) if ( filter ( cursor ) ) result . push ( cursor ) ; break ; case AXIS_PARENT : if ( filter ( root [ PARENT_NODE ] ) ) result . push ( root [ PARENT_NODE ] ) ; break ; case AXIS_PRECEDING : walker = new TreeWalker ( root , filter , TreeWalker . BACKWARD ) ; walker . cursor_ = root [ PREVIOUS_SIBLING ] || root [ PARENT_NODE ] ; while ( cursor = walker . next ( ) ) result . push ( cursor ) ; break ; case AXIS_PRECEDING_SIBLING : cursor = root ; while ( cursor = cursor [ PREVIOUS_SIBLING ] ) if ( filter ( cursor ) ) result . push ( cursor ) ; break ; } return result ; }
Navigation  
Returns nodes axis in XPath like way.
@param {Node} root Relative point for axis.
@param {number} axis Axis constant.
@param {function(node:Node):boolean} filter Filter function. If it's returns true node will be in result list.
@return {Array.<Node>}
Navigation Returns nodes axis in XPath like way .