* Looks for directives on the given node and adds them to the directive collection which is * sorted. * * @param node Node to search. * @param directives An array to which the directives are added to. This array is sorted before * the function returns. * @param a
(node, directives, attrs, maxPriority, ignoreDirective)
| 8011 | * @param {number=} maxPriority Max directive priority. |
| 8012 | */ |
| 8013 | function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { |
| 8014 | var nodeType = node.nodeType, |
| 8015 | attrsMap = attrs.$attr, |
| 8016 | match, |
| 8017 | nodeName, |
| 8018 | className; |
| 8019 | |
| 8020 | switch (nodeType) { |
| 8021 | case NODE_TYPE_ELEMENT: /* Element */ |
| 8022 | |
| 8023 | nodeName = nodeName_(node); |
| 8024 | |
| 8025 | // use the node name: <directive> |
| 8026 | addDirective(directives, |
| 8027 | directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective); |
| 8028 | |
| 8029 | // iterate over the attributes |
| 8030 | for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, |
| 8031 | j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { |
| 8032 | var attrStartName = false; |
| 8033 | var attrEndName = false; |
| 8034 | |
| 8035 | attr = nAttrs[j]; |
| 8036 | name = attr.name; |
| 8037 | value = trim(attr.value); |
| 8038 | |
| 8039 | // support ngAttr attribute binding |
| 8040 | ngAttrName = directiveNormalize(name); |
| 8041 | if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { |
| 8042 | name = name.replace(PREFIX_REGEXP, '') |
| 8043 | .substr(8).replace(/_(.)/g, function(match, letter) { |
| 8044 | return letter.toUpperCase(); |
| 8045 | }); |
| 8046 | } |
| 8047 | |
| 8048 | var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE); |
| 8049 | if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) { |
| 8050 | attrStartName = name; |
| 8051 | attrEndName = name.substr(0, name.length - 5) + 'end'; |
| 8052 | name = name.substr(0, name.length - 6); |
| 8053 | } |
| 8054 | |
| 8055 | nName = directiveNormalize(name.toLowerCase()); |
| 8056 | attrsMap[nName] = name; |
| 8057 | if (isNgAttr || !attrs.hasOwnProperty(nName)) { |
| 8058 | attrs[nName] = value; |
| 8059 | if (getBooleanAttrName(node, nName)) { |
| 8060 | attrs[nName] = true; // presence means true |
| 8061 | } |
| 8062 | } |
| 8063 | addAttrInterpolateDirective(node, directives, value, nName, isNgAttr); |
| 8064 | addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName, |
| 8065 | attrEndName); |
| 8066 | } |
| 8067 | |
| 8068 | if (nodeName === 'input' && node.getAttribute('type') === 'hidden') { |
| 8069 | // Hidden input elements can have strange behaviour when navigating back to the page |
| 8070 | // This tells the browser not to try to cache and reinstate previous values |
no test coverage detected