browser/libs/dom.js
function _getElement(name, parentNode) {
    if (name === '') name = null;
    var _elem;
    var _isarr = false;
    if (typeof name === 'string') {
      if (name[0] == '<') {
        _elem = window.document.createElement('div');
        _elem.innerHTML = name;
        if (_elem.childNodes.length == 1) {
          _elem = _elem.childNodes[0];
          _isarr = false;
        }
        else {
          _elem = _elem.childNodes;
          _isarr = true;
        }
      }
      else {
        if (name.indexOf('<') > 0 || name.indexOf('>') > 0)
          throw new Error('Syntax error, unrecognized');

        var names = name.split(' ');
        var nodes = parentNode ? [parentNode] : null;
        for (var i = 0; i < names.length; i++) {
          if (names[i] != '')
            nodes = _matchElement(nodes, names[i], !!parentNode);
        }
        if (nodes.length <= 1) {
          _elem = nodes[0];
          _isarr = false;
        } else {
          _elem = nodes;
          _isarr = true;
        }
      }
    } else {
      _elem = name;
    }
    return {_elem, _isarr};
  }
function _getElement(name, parentNode) {
    if (name === '') name = null;
    var _elem;
    var _isarr = false;
    if (typeof name === 'string') {
      if (name[0] == '<') {
        _elem = window.document.createElement('div');
        _elem.innerHTML = name;
        if (_elem.childNodes.length == 1) {
          _elem = _elem.childNodes[0];
          _isarr = false;
        }
        else {
          _elem = _elem.childNodes;
          _isarr = true;
        }
      }
      else {
        if (name.indexOf('<') > 0 || name.indexOf('>') > 0)
          throw new Error('Syntax error, unrecognized');

        var names = name.split(' ');
        var nodes = parentNode ? [parentNode] : null;
        for (var i = 0; i < names.length; i++) {
          if (names[i] != '')
            nodes = _matchElement(nodes, names[i], !!parentNode);
        }
        if (nodes.length <= 1) {
          _elem = nodes[0];
          _isarr = false;
        } else {
          _elem = nodes;
          _isarr = true;
        }
      }
    } else {
      _elem = name;
    }
    return {_elem, _isarr};
  }
function _getElement ( name , parentNode ) { if ( name === '' ) name = null ; var _elem ; var _isarr = false ; if ( typeof name === 'string' ) { if ( name [ 0 ] == '<' ) { _elem = window . document . createElement ( 'div' ) ; _elem . innerHTML = name ; if ( _elem . childNodes . length == 1 ) { _elem = _elem . childNodes [ 0 ] ; _isarr = false ; } else { _elem = _elem . childNodes ; _isarr = true ; } } else { if ( name . indexOf ( '<' ) > 0 || name . indexOf ( '>' ) > 0 ) throw new Error ( 'Syntax error, unrecognized' ) ; var names = name . split ( ' ' ) ; var nodes = parentNode ? [ parentNode ] : null ; for ( var i = 0 ; i < names . length ; i ++ ) { if ( names [ i ] != '' ) nodes = _matchElement ( nodes , names [ i ] , ! ! parentNode ) ; } if ( nodes . length <= 1 ) { _elem = nodes [ 0 ] ; _isarr = false ; } else { _elem = nodes ; _isarr = true ; } } } else { _elem = name ; } return { _elem , _isarr } ; }
- parentNode 仅筛选此节点下的节点.
- parentNode 仅筛选此节点下的节点 .