* 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)
| 8856 | * @param {number=} maxPriority Max directive priority. |
| 8857 | */ |
| 8858 | function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { |
| 8859 | var nodeType = node.nodeType, |
| 8860 | attrsMap = attrs.$attr, |
| 8861 | match, |
| 8862 | nodeName, |
| 8863 | className; |
| 8864 | |
| 8865 | switch (nodeType) { |
| 8866 | case NODE_TYPE_ELEMENT: /* Element */ |
| 8867 | |
| 8868 | nodeName = nodeName_(node); |
| 8869 | |
| 8870 | // use the node name: <directive> |
| 8871 | addDirective(directives, |
| 8872 | directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective); |
| 8873 | |
| 8874 | // iterate over the attributes |
| 8875 | for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, |
| 8876 | j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { |
| 8877 | var attrStartName = false; |
| 8878 | var attrEndName = false; |
| 8879 | |
| 8880 | attr = nAttrs[j]; |
| 8881 | name = attr.name; |
| 8882 | value = trim(attr.value); |
| 8883 | |
| 8884 | // support ngAttr attribute binding |
| 8885 | ngAttrName = directiveNormalize(name); |
| 8886 | isNgAttr = NG_ATTR_BINDING.test(ngAttrName); |
| 8887 | if (isNgAttr) { |
| 8888 | name = name.replace(PREFIX_REGEXP, '') |
| 8889 | .substr(8).replace(/_(.)/g, function(match, letter) { |
| 8890 | return letter.toUpperCase(); |
| 8891 | }); |
| 8892 | } |
| 8893 | |
| 8894 | var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE); |
| 8895 | if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) { |
| 8896 | attrStartName = name; |
| 8897 | attrEndName = name.substr(0, name.length - 5) + 'end'; |
| 8898 | name = name.substr(0, name.length - 6); |
| 8899 | } |
| 8900 | |
| 8901 | nName = directiveNormalize(name.toLowerCase()); |
| 8902 | attrsMap[nName] = name; |
| 8903 | if (isNgAttr || !attrs.hasOwnProperty(nName)) { |
| 8904 | attrs[nName] = value; |
| 8905 | if (getBooleanAttrName(node, nName)) { |
| 8906 | attrs[nName] = true; // presence means true |
| 8907 | } |
| 8908 | } |
| 8909 | addAttrInterpolateDirective(node, directives, value, nName, isNgAttr); |
| 8910 | addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName, |
| 8911 | attrEndName); |
| 8912 | } |
| 8913 | |
| 8914 | if (nodeName === 'input' && node.getAttribute('type') === 'hidden') { |
| 8915 | // Hidden input elements can have strange behaviour when navigating back to the page |
no test coverage detected