selector에서 attr을 분류, {length:조건의 갯수, node, id, className:Array, attr:Array}, 예) img[src*=gif].list[alt*=img]
504806
function ( selector ) {
            var result = {}, index = 0;
    
            selector.replace( /([a-z]+)?(\#\w+)?(\.\w+)?(\[[^\[\]]+\])?/ig, function ( str, node, id, className, attr ) {
                if ( node ) result.node = node.toLowerCase(), index++;
                if ( id ) result.id = id.replace(/^\#/, ''), index++;
    
                //class 복수조건 가능
                if ( className ) {
                    var reClass = className.replace(/^\./, '');
                    if ( result.className ) {
                        result.className.push( reClass );
                    } else {
                        result.className = [reClass];
                    }
                    index++;
                }
                //attr 복수조건 가능
                if ( attr ) {
                    var reAttr = attr.replace(/[\s\"\'\[\]]/g, '');
                    if ( result.attr ) {
                        result.attr.push( reAttr );
                    } else {
                        result.attr = [reAttr];
                    }
                    index++;
                }
            });
    
            result.length = index;
            return result;
        }
148247
public static function img($src, $attr = array())
	{
		if ( ! preg_match('#^(\w+://)# i', $src))
		{
			$src = \Uri::base(false).$src;
		}
		$attr['src'] = $src;
		$attr['alt'] = (isset($attr['alt'])) ? $attr['alt'] : pathinfo($src, PATHINFO_FILENAME);
		return html_tag('img', $attr);
	}
655252
private void displayNode(JspWriter out, ViewNode node, String url_Path, int level, int width) throws IOException {

		// ----------------------------------------显示节点本身信息，如节点名称等开始
		String encodedNodeKey = URLEncoder.encode(node.getKey(), "UTF-8");
		String action = replace(nodeAction, "${key}", encodedNodeKey);
		StringBuilder url = new StringBuilder(url_Path);
		url.append(action);
		if (nodeAction.indexOf("?") < 0)
			url.append("?");
		else
			url.append("&");
		url.append("key=").append(node.getKey());
		String treeNodeAction = url.toString();

		url = new StringBuilder(url_Path);
		url.append(treeAction);
		if (treeAction.indexOf("?") < 0)
			url.append("?");
		else
			url.append("&");
		url.append("select=").append(node.getKey());
		String updateNodeAction = url.toString();

		// Render the label for this node (if any)
		out.print("    <td colspan=\"");
		out.print(width - level + 1);
		out.print("\">");

		// 这里省略了icon

		if (node.getLabel() != null) {
			String labelStyle = null;
			if (node.isSelected())
				labelStyle = CSS_STYLE_SELECTED;
			else if (!node.isSelected())
				labelStyle = CSS_STYLE_UN_SELECTED;
			if (treeNodeAction != null) {
				// Note the leading space so that the text has some space
				// between it and any preceding images
				out.print(" <a href=\"");
				out.print(treeNodeAction);
				out.print("\"");
				if (target != null) {
					out.print(" target=\"");
					out.print(target);
					out.print("\"");
				}
				if (labelStyle != null) {
					out.print(" class=\"");
					out.print(labelStyle);
					out.print("\"");
				}
				// to refresh the tree in the same 'self' frame
				out.print(" onclick=\"");
				out.print("self.location.href='" + updateNodeAction + "'");
				out.print("\"");
				out.print(">");
			} else if (labelStyle != null) {
				out.print("<span class=\"");
				out.print(labelStyle);
				out.print("\">");
			}
			out.print(node.getLabel());
			if (treeNodeAction != null)
				out.print("</a>");
			else if (labelStyle != null)
				out.print("</span>");
		}

		out.println("</td>");

		// ----------------------------------------显示节点本身信息，如节点名称等结束

	}
178291
function getAttrs(element) {
  return Array.from(element.attributes).reduce((attrs, attr) => {
    attrs[attr.name] = attr.value;
    return attrs;
  }, {});
}
310577
function extract(selectorText) {
    var attr = 0,
        sels = [],
        sel = '',
        i,
        c,
        l = selectorText.length;

    for (i = 0; i < l; i++) {
        c = selectorText.charAt(i);

        if (attr) {
            if (c === '[' || c === '(') {
                attr--;
            }
            sel += c;
        } else if (c === ',') {
            sels.push(sel);
            sel = '';
        } else {
            if (c === '[' || c === '(') {
                attr++;
            }
            if (sel.length || (c !== ',' && c !== '\n' && c !== ' ')) {
                sel += c;
            }
        }
    }

    if (sel.length) {
        sels.push(sel);
    }

    return sels;
}
847060
function ( selector ) {
            var node = this.element().nextSibling;
            if ( !node ) return;
    
            //comment, text
            if ( node.nodeType == 8 || node.nodeType == 3 && !$B.string.trim(node.data) ) {
                return $B( node ).next( selector );
            } else {
                if ( typeof selector === 'string' ) node = $B.selector.match( node, selector )? node : undefined;
                return node;
            }
        }
918489
function changeSrc (childList, imgIndex, arraySrc) {
  // 由于懒加载方案是修改 src，所以在第一次加载图片的时候需要修改所有图片的 src，如若不是图片('no-src')则重定向，防止404。
  let src = arraySrc[imgIndex] !== 'no-src' ? arraySrc[imgIndex] : '?mip_img_ori=1'
  for (let i = 0; i < childList.length; i++) {
    if (childList[i].tagName === 'MIP-IMG') {
      childList[i].setAttribute('src', src)
    } else {
      let mipImg = childList[i].querySelector('mip-img')
      mipImg && mipImg.setAttribute('src', src)
    }
  }
  return childList
}
736503
function(selector) {
            selector = selector || '';
            selector = Selector._replaceShorthand(Y.Lang.trim(selector)); 
            var token = Selector._getToken(),     // one token per simple selector (left selector holds combinator)
                query = selector, // original query for debug report
                tokens = [],    // array of tokens
                found = false,  // whether or not any matches were found this pass
                match,         // the regex match
                test,
                i, parser;

            /*
                Search for selector patterns, store, and strip them from the selector string
                until no patterns match (invalid selector) or we run out of chars.

                Multiple attributes and pseudos are allowed, in any order.
                for example:
                    'form:first-child[type=button]:not(button)[lang|=en]'
            */
            outer:
            do {
                found = false; // reset after full pass
                for (i = 0; (parser = Selector._parsers[i++]);) {
                    if ( (match = parser.re.exec(selector)) ) { // note assignment
                        if (parser.name !== COMBINATOR ) {
                            token.selector = selector;
                        }
                        selector = selector.replace(match[0], ''); // strip current match from selector
                        if (!selector.length) {
                            token.last = true;
                        }

                        if (Selector._attrFilters[match[1]]) { // convert class to className, etc.
                            match[1] = Selector._attrFilters[match[1]];
                        }

                        test = parser.fn(match, token);
                        if (test === false) { // selector not supported
                            found = false;
                            break outer;
                        } else if (test) {
                            token.tests.push(test);
                        }

                        if (!selector.length || parser.name === COMBINATOR) {
                            tokens.push(token);
                            token = Selector._getToken(token);
                            if (parser.name === COMBINATOR) {
                                token.combinator = Y.Selector.combinators[match[1]];
                            }
                        }
                        found = true;
                    }
                }
            } while (found && selector.length);

            if (!found || selector.length) { // not fully parsed
                tokens = [];
            }
            return tokens;
        }
937186
function (selector) {
            var nodes = [];
            if (vQ.isFunction(selector) && selector.call !== undefined) {
                this.each(function (idx) {
                    if (!selector.call(this, idx)) nodes.push(this);
                });
            } else {
                var excludes = typeof selector == 'string' ?
                    this.filter(selector) : (vQ.isArrayLike(selector) && vQ.isFunction(selector.item)) ? slice.call(selector) : vQ(selector);
                this.each(function (inx, el) {
                    if (excludes.indexOf(el) < 0){
                        nodes.push(el);
                    }
                });
            }
            return vQ(nodes);
        }
578189
function ( el, attrs ) {
            var i, attrNum = attrs.length, result = false;
    
            for ( i = 0; i < attrNum; ++i ) {
                //parseAttr
                //attrs[i].replace( /(^\w+)([\=\$\*\~\^]{1,2})?([\w\W]+)?|(^\w+)([^\=\$\*\~\^]+)/, function ( str, name, operator, value ) {
                attrs[i].replace( /(^\w+)([=$*~\^]{1,2})?([\w\W]+)?|(^\w+)([^=$*~\^]+)/, function ( str, name, operator, value ) {
                    if ( name ) {
                        var elValue = $B( el ).attr( name ),
                            reValue;
    
                        if ( operator ) {
                            if ( !elValue ) return;
    
                            //연산자
                            switch ( operator ) {
                                case '=':
                                    result = ( elValue == value );
                                    break;
                                case '*=':
                                    result = ( elValue.indexOf(value) > -1 );
                                    break;
                                case '~=':
                                    result = $B.string.isWholeWord( elValue, value );
                                    break;
                                case '^=':
                                    reValue = value.replace( /[(){}[\]*+?.\\^$|,\-]/g, '\\$&' );
                                    result = new RegExp( '^' + reValue ).test( elValue );
                                    break;
                                case '$=':
                                    reValue = value.replace( /[(){}[\]*+?.\\^$|,\-]/g, '\\$&' );
                                    result = new RegExp( reValue + '$' ).test( elValue );
                                    break;
                            }
                            //attr이 있는지 비교만 할때
                        } else {
                            result = ( !elValue )? false : true;
                        }
                    } else {
                        return false;
                    }
                });
    
                //하나라도 false가 나오면 더이상 체크하지 않는다.
                if ( !result ) return result;
            }
    
            return result;
        }
923691
function querySelector(selector) {
    init();
    if (!selector) {
      return tokens;
    }
    var match = selector.match(
      /^\s*([\w_-]*)((\s*\[[\w_-]+\s*=\s*("([^\\"]*(\\.)*)*"|'([^\\']*(\\.)*)*'|[^\[\]]*)\])*)\s*(\*?)$/
    );
    if (!match) {
      console.warn(colors.blue('Invalid selector expressions %j.'), selector);
      return;
    }
    var tag = match[1];
    var attributes = [];
    var all = match[9] === '*';
    match[2].replace(/\s*\[([\w_-]+)\s*=\s*("([^\\"]*(\\.)*)*"|'([^\\']*(\\.)*)*'|[^\[\]]*)\]/g,
      function (match, name, value) {
        if (/^['"]/.test(value)) {
          /*jslint evil: true */
          value = new Function('return (' + value + ');')();
        }
        attributes.push({
          name: name,
          value: value
        });
      }
    );
    function check(node) {
      if (!node || !node.attrs) {
        return;
      }
      var flag;
      if (!tag || node.tag === tag) {
        flag = true;
        attributes.every(function (item) {
          if (item.value !== node.attrs[item.name]) {
            flag = false;
          }
          return flag;
        });
      }
      return flag;
    }
    var items;
    function scan(node) {
      if (check(node)) {
        if (items) {
          items.push(node);
        }
        return node;
      }
      var result;
      if (node.nodes) {
        node.nodes.every(function (item) {
          result = scan(item);
          return items || !result;
        });
      }
      return result;
    }
    if (all) {
      items = [];
      scan(tokens);
      return items;
    }
    else {
      return scan(tokens);
    }
  }
1116294
function parseAttributes(attrStr) {
    var reAttributes = /([^=<>\"\'\s]+)\s*(?:=\s*["']?([^"']*)["']?)?/g;
    var result = {};
    var match;

    if (attrStr) {
        while (match = reAttributes.exec(attrStr)) {
            result[match[1]] = match[2] || true;
        }
    }

    return result;
}
1087050
function getImageSrcHTML(node) {
	const srcAttr = getAttribute(node, 'src');
	if (!srcAttr) {
		console.warn('No "src" attribute in', node && node.open);
		return;
	}

	return srcAttr.value.value;
}
1290331
function(attr) {
      var html;
      if (html = this._escapedAttributes[attr]) return html;
      var val = this.attributes[attr];
      return this._escapedAttributes[attr] = escapeHTML(val == null ? '' : '' + val);
    }
985227
function(selector) {
        var token = {},     // one token per simple selector (left selector holds combinator)
            tokens = [],    // array of tokens
            id,             // unique id for the simple selector (if found)
            found = false,  // whether or not any matches were found this pass
            patterns = Y.Selector._patterns,
            match;          // the regex match

        selector = Y.Selector._replaceShorthand(selector); // convert ID and CLASS shortcuts to attributes

        /*
            Search for selector patterns, store, and strip them from the selector string
            until no patterns match (invalid selector) or we run out of chars.

            Multiple attributes and pseudos are allowed, in any order.
            for example:
                'form:first-child[type=button]:not(button)[lang|=en]'
        */
        do {
            found = false; // reset after full pass
            for (var re in patterns) {
                if (YAHOO.lang.hasOwnProperty(patterns, re)) {
                    if (re != 'tag' && re != 'combinator') { // only one allowed
                        token[re] = token[re] || [];
                    }
                    if ( (match = patterns[re].exec(selector)) ) { // note assignment
                        found = true;
                        if (re != 'tag' && re != 'combinator') { // only one allowed
                            // capture ID for fast path to element
                            if (re === 'attributes' && match[1] === 'id') {
                                token.id = match[3];
                            }

                            token[re].push(match.slice(1));
                        } else { // single selector (tag, combinator)
                            token[re] = match[1];
                        }
                        selector = selector.replace(match[0], ''); // strip current match from selector
                        if (re === 'combinator' || !selector.length) { // next token or done
                            token.attributes = Y.Selector._fixAttributes(token.attributes);
                            token.pseudos = token.pseudos || [];
                            token.tag = token.tag ? token.tag.toUpperCase() : '*';
                            tokens.push(token);

                            token = { // prep next token
                                previous: token
                            };
                        }
                    }
                }
            }
        } while (found);

        return tokens;
    }
131010
def check_attr(node, n):
        
        if len(node.children) > n:
            return node.children[n]
403455
function AncView(selector) {
        var _this = _super.call(this) || this;
        // 绑定该视图
        var viewId = _this.constructor.toString().match(/^function\s*([^\s(]+)/)[1];
        if (!selector) {
            selector = "#" + viewId;
        }
        _this.SetSelector(selector);
        _this.SetName(viewId);
        _this.LoadView();
        _this.Inject();
        _this.Show();
        return _this;
    }