/*
执行方法, 将Node或Attribute的内容写入对象属性中
554178
private void setMethod(Method method, Object targetObject, Object value) throws UnmarshalException {
		try {
			method.invoke(targetObject, value);
		} catch (IllegalArgumentException e) {
			throw new UnmarshalException(e);
		} catch (IllegalAccessException e) {
			throw new UnmarshalException(e);
		} catch (InvocationTargetException e) {
			throw new UnmarshalException(e);
		}
	}
595044
function(node, attrName, baseUrl){
			var i,
				nodes,
				attr;

			nodes = modules.domUtils.getNodesByAttribute(node, attrName);
			i = nodes.length;
			while (i--) {
				try{
					// the url parser can blow up if the format is not right
					attr = modules.domUtils.getAttribute(nodes[i], attrName);
					if(attr && attr !== '' && baseUrl !== '' && attr.indexOf('://') === -1) {
						//attr = urlParser.resolve(baseUrl, attr);
						attr = modules.url.resolve(attr, baseUrl);
						modules.domUtils.setAttribute(nodes[i], attrName, attr);
					}
				}catch(err){
					// do nothing - convert only the urls we can, leave the rest as they are
				}
			}
		}
578013
function(node, attributeName) {
			var out = [],
				attList;

			attList = node.getAttribute(attributeName);
			if(attList && attList !== '') {
				if(attList.indexOf(' ') > -1) {
					out = attList.split(' ');
				} else {
					out.push(attList);
				}
			}
			return out;
		}
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>");

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

	}
1101948
function walk(node) {
            if (node.tag) {
                var attrText = " data-brackets-id='" + node.tagID + "'";

                // If the dom was fully rebuilt, use its offsets. Otherwise, use the marks in the
                // associated editor, since they'll be more up to date.
                var startOffset;
                if (dom.fullBuild) {
                    startOffset = node.start;
                } else {
                    var mark = markCache[node.tagID];
                    if (mark) {
                        startOffset = editor._codeMirror.indexFromPos(mark.range.from);
                    } else {
                        console.warn("generateInstrumentedHTML(): couldn't find existing mark for tagID " + node.tagID);
                        startOffset = node.start;
                    }
                }

                // Insert the attribute as the first attribute in the tag.
                var insertIndex = startOffset + node.tag.length + 1;
                gen += orig.substr(lastIndex, insertIndex - lastIndex) + attrText;
                lastIndex = insertIndex;

                // If we have a script to inject and this is the head tag, inject it immediately
                // after the open tag.
                if (remoteScript && !remoteScriptInserted && node.tag === "head") {
                    insertIndex = node.openEnd;
                    gen += orig.substr(lastIndex, insertIndex - lastIndex) + remoteScript;
                    lastIndex = insertIndex;
                    remoteScriptInserted = true;
                }
            }

            if (node.isElement()) {
                node.children.forEach(walk);
            }
        }
704263
private void mapAttributes(List<Attribute> input, Map<String, List<Attribute>> output) {
        Iterator<Attribute> it = input.iterator();
        while (it.hasNext()) {
            Attribute attr = it.next();
            String id = attr.getId().toString();

            if (output.containsKey(id)) {
                List<Attribute> list = output.get(id);
                list.add(attr);
            } else {
                List list = new ArrayList<Attribute>();
                list.add(attr);
                output.put(id, list);
            }
        }
    }
831886
private void encodeAttributes(List attributes, PrintStream out,
                                  Indenter indenter) {
        Iterator it = attributes.iterator();
        while (it.hasNext()) {
            Attribute attr = (Attribute)(it.next());
            attr.encode(out, indenter);
        }
    }
81117
private void appendAttribute(Appendable buf, String attrName, String encodedValue) throws IOException {
        buf.append(' ').append(attrName).append('=').append('\"').append(encodedValue).append('\"');
    }
605322
private Expression getStaticContent(HtmlAttributeNode node) {
    if (!node.hasValue()) {
      return Expression.stringLiteral("");
    }
    // This case is some control flow like a switch, if, or for loop.
    if (!(node.getChild(1) instanceof HtmlAttributeValueNode)) {
      return null;
    }
    HtmlAttributeValueNode attrValue = (HtmlAttributeValueNode) node.getChild(1);
    if (attrValue.numChildren() == 0) {
      return Expression.stringLiteral("");
    }
    // If any children are not raw text or constant xid/css calls, return null
    for (int i = 0; i < attrValue.numChildren(); i++) {
      if (attrValue.getChild(i) instanceof RawTextNode) {
        continue;
      } else if (attrValue.getChild(i) instanceof PrintNode) {
        PrintNode n = (PrintNode) attrValue.getChild(i);
        if (n.getExpr().getRoot() instanceof FunctionNode) {
          FunctionNode fnNode = (FunctionNode) n.getExpr().getRoot();
          if (fnNode.getSoyFunction() != BuiltinFunction.XID
              && fnNode.getSoyFunction() != BuiltinFunction.CSS) {
            return null; // Function call was not xid or css
          }
        } else {
          // Child is variable expression ie {$foo} or {$foo + $bar}
          return null;
        }
      } else {
        // Child was control flow.
        return null;
      }
    }
    return CodeChunkUtils.concatChunksForceString(getAttributeValues(node));
  }
970700
function(d) {
        var a = d.attributes, i;
        if (a) {
          for (i = 0; i < a.length; i += 1) {
            if (typeof d[a[i].name] === 'function') d[a[i].name] = null;
          }
        }
        a = d.childNodes;
        if (a) {
          for (i = 0; i < a.length; i += 1) purge(d.childNodes[i]);
        }
      }
992751
def apply_attribute(node: Node, attr: XmlAttr):
    """"""
    setter = get_setter(attr)
    stripped_value = attr.value.strip() if attr.value else ''
    if is_expression(stripped_value):
        (binding_type, expr_body) = parse_expression(stripped_value)
        binder().apply(binding_type, node=node, attr=attr, modifier=setter, expr_body=expr_body)
    else:
        setter(node, attr.name, attr.value)
1145263
function(node) {
        // node is either a wpt, trk or rte
        // attributes are children of the form <attr>value</attr>
        var attributes = {};
        var attrNode = node.firstChild, value, name;
        while(attrNode) {
            if(attrNode.nodeType == 1 && attrNode.firstChild) {
                value = attrNode.firstChild;
                if(value.nodeType == 3 || value.nodeType == 4) {
                    name = (attrNode.prefix) ?
                        attrNode.nodeName.split(":")[1] :
                        attrNode.nodeName;
                    if(name != "trkseg" && name != "rtept") {
                        attributes[name] = value.nodeValue;
                    }
                }
            }
            attrNode = attrNode.nextSibling;
        }
        return attributes;
    }
1089809
private ImmutableMap<String, Expression> getStaticAttributes(HtmlOpenTagNode node) {
    List<HtmlAttributeNode> nodesToRemove = new ArrayList<>();
    ImmutableMap.Builder<String, Expression> builder = ImmutableMap.builder();
    // The 0th index is actually the tag itself, so we don't need to iterate over it.
    for (int i = 1; i < node.numChildren(); i++) {
      if (node.getChild(i) instanceof HtmlAttributeNode) {
        HtmlAttributeNode attrNode = (HtmlAttributeNode) node.getChild(i);
        String attributeKey = attrNode.getStaticKey();
        Expression value = getStaticContent(attrNode);
        if (attributeKey != null && value != null) {
          nodesToRemove.add(attrNode);
          builder.put(attributeKey, value);
        }
      }
    }

    for (HtmlAttributeNode child : nodesToRemove) {
      node.removeChild(child);
    }
    return builder.build();
  }
605715
function jsTreeCtrl() {
        /*jshint validthis:true */
        var nodeSerialId = 1;
        var vm = this;

        vm.nodesFingerprint = function (e) {
            if (!e.__uiNodeId) {
                e.__uiNodeId = nodeSerialId++;
            }
            return '' + e.__uiNodeId + (e.id || '') + (e.text || '') + (e.type || '');
        };

        vm.changeWatcher = function (arraySource, tokenFn) {
            var self;
            var getTokens = function () {
                var result = [], token, el;
                if (arraySource) {
                    var array = angular.isFunction(arraySource) ? arraySource() : arraySource;
                    for (var i = 0, n = array.length; i < n; i++) {
                        el = array[i];
                        token = tokenFn(el);
                        map[token] = el;
                        result.push(token);
                    }
                }
                return result;
            };
            // returns elements in that are in a but not in b
            // subtractAsSets([4, 5, 6], [4, 5, 7]) => [6]
            var subtractAsSets = function (a, b) {
                var result = [], inB = {}, i, n;
                for (i = 0, n = b.length; i < n; i++) {
                    inB[b[i]] = true;
                }
                for (i = 0, n = a.length; i < n; i++) {
                    if (!inB[a[i]]) {
                        result.push(a[i]);
                    }
                }
                return result;
            };

            // Map objects to tokens and vice-versa
            var map = {};

            var applyChanges = function (newTokens, oldTokens) {
                var i, n, el, token;
                var replacedTokens = {};
                var removedTokens = subtractAsSets(oldTokens, newTokens);
                for (i = 0, n = removedTokens.length; i < n; i++) {
                    var removedToken = removedTokens[i];
                    el = map[removedToken];
                    delete map[removedToken];
                    var newToken = tokenFn(el);
                    // if the element wasn't removed but simply got a new token, its old token will be different from the current one
                    if (newToken === removedToken) {
                        self.onRemoved(el);
                    } else {
                        replacedTokens[newToken] = removedToken;
                        self.onChanged(el);
                    }
                }

                var addedTokens = subtractAsSets(newTokens, oldTokens);
                for (i = 0, n = addedTokens.length; i < n; i++) {
                    token = addedTokens[i];
                    el = map[token];
                    if (!replacedTokens[token]) {
                        self.onAdded(el);
                    }
                }

            };
            self = {
                subscribe: function (scope, onChanged) {
                    scope.$watch(getTokens, function (newTokens, oldTokens) {
                        if (!onChanged || onChanged(newTokens, oldTokens) !== false) {
                            applyChanges(newTokens, oldTokens);
                        }
                    }, true);
                },
                onAdded: angular.noop,
                onChanged: angular.noop,
                onRemoved: angular.noop
            };
            return self;
        };
    }
220213
def _process_getattr(self, node, **kwargs):
        

        with self._interpolation():
            with self._python_bool_wrapper(**kwargs) as new_kwargs:
                if is_loop_helper(node):
                    self._process_loop_helper(node, **new_kwargs)
                else:
                    self._process_node(node.node, **new_kwargs)
                    self.output.write('.')
                    self.output.write(node.attr)
218524
function htmlTreeAsString (elem) {
  var MAX_TRAVERSE_HEIGHT = 5
  var MAX_OUTPUT_LEN = 80
  var out = []
  var height = 0
  var len = 0
  var separator = ' > '
  var sepLength = separator.length
  var nextStr

  while (elem && height++ < MAX_TRAVERSE_HEIGHT) {
    nextStr = htmlElementAsString(elem)
    // bail out if
    // - nextStr is the 'html' element
    // - the length of the string that would be created exceeds MAX_OUTPUT_LEN
    //   (ignore this limit if we are on the first iteration)
    if (
      nextStr === 'html' ||
      (height > 1 &&
       len + (out.length * sepLength) + nextStr.length >= MAX_OUTPUT_LEN)
    ) {
      break
    }

    out.push(nextStr)

    len += nextStr.length
    elem = elem.parentNode
  }

  return out.reverse().join(separator)
}
715520
function walk(node, output, previousNode) {

  // tag name
  validator.checkTagName(node, output)

  // attrs: id/class/style/if/repeat/append/event/attr
  var attrs = node.attrs || []
  attrs.forEach(function switchAttr(attr) {
    var name = attr.name
    var value = attr.value

    var locationInfo = {line: 1, column: 1}
    if (node.__location) {
      locationInfo = {
        line: node.__location.line,
        column: node.__location.col
      }
    }

    switch (name) {
      case 'id':
      validator.checkId(value, output)
      break
      case 'class':
      validator.checkClass(value, output)
      break
      case 'style':
      validator.checkStyle(value, output, locationInfo)
      break
      case 'if':
      validator.checkIf(value, output)
      break
      case 'else':
      previousNode && previousNode.attrs.forEach(function (attr) {
        if (attr.name === 'if') {
          validator.checkIf(attr.value, output, true)
        }
      })
      break
      case 'repeat':
      validator.checkRepeat(value, output)
      break
      case 'append':
      validator.checkAppend(value, output)
      break
      default:
      if (name.match(/^on/)) {
        validator.checkEvent(name, value, output)
      }
      else {
        validator.checkAttr(name, value, output, node.tagName, locationInfo)
      }
    }
  })

  // children
  var originResult = output.result
  var childNodes = node.childNodes
  if (childNodes && childNodes.length) {

    var previous // FIXME: `parse5` has no previous sibling element information
    childNodes.forEach(function (child, i) {
      if (i > 0) {
        previous = childNodes[i - 1]
      }
      if (child.nodeName.match(/^#/)) {
        // special rules for text content in <text>
        if (child.nodeName === '#text' && child.value.trim()) {
          var tempResult = output.result
          output.result = originResult
          validator.checkAttr('value', child.value, output)
          output.result = tempResult
        }
        return
      }
      var childResult = {}
      output.result = childResult
      originResult.children = originResult.children || []
      originResult.children.push(childResult)
      walk(child, output, previous)
    })
  }
  output.result = originResult
}