* 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)
| 9972 | * @param {number=} maxPriority Max directive priority. |
| 9973 | */ |
| 9974 | function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { |
| 9975 | var nodeType = node.nodeType, |
| 9976 | attrsMap = attrs.$attr, |
| 9977 | match, |
| 9978 | nodeName, |
| 9979 | className; |
| 9980 | |
| 9981 | switch (nodeType) { |
| 9982 | case NODE_TYPE_ELEMENT: /* Element */ |
| 9983 | |
| 9984 | nodeName = nodeName_(node); |
| 9985 | |
| 9986 | // use the node name: <directive> |
| 9987 | addDirective(directives, |
| 9988 | directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective); |
| 9989 | |
| 9990 | // iterate over the attributes |
| 9991 | for (var attr, name, nName, value, ngPrefixMatch, nAttrs = node.attributes, |
| 9992 | j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { |
| 9993 | var attrStartName = false; |
| 9994 | var attrEndName = false; |
| 9995 | |
| 9996 | var isNgAttr = false, isNgProp = false, isNgEvent = false; |
| 9997 | var multiElementMatch; |
| 9998 | |
| 9999 | attr = nAttrs[j]; |
| 10000 | name = attr.name; |
| 10001 | value = attr.value; |
| 10002 | |
| 10003 | nName = directiveNormalize(name.toLowerCase()); |
| 10004 | |
| 10005 | // Support ng-attr-*, ng-prop-* and ng-on-* |
| 10006 | if ((ngPrefixMatch = nName.match(NG_PREFIX_BINDING))) { |
| 10007 | isNgAttr = ngPrefixMatch[1] === 'Attr'; |
| 10008 | isNgProp = ngPrefixMatch[1] === 'Prop'; |
| 10009 | isNgEvent = ngPrefixMatch[1] === 'On'; |
| 10010 | |
| 10011 | // Normalize the non-prefixed name |
| 10012 | name = name.replace(PREFIX_REGEXP, '') |
| 10013 | .toLowerCase() |
| 10014 | .substr(4 + ngPrefixMatch[1].length).replace(/_(.)/g, function(match, letter) { |
| 10015 | return letter.toUpperCase(); |
| 10016 | }); |
| 10017 | |
| 10018 | // Support *-start / *-end multi element directives |
| 10019 | } else if ((multiElementMatch = nName.match(MULTI_ELEMENT_DIR_RE)) && directiveIsMultiElement(multiElementMatch[1])) { |
| 10020 | attrStartName = name; |
| 10021 | attrEndName = name.substr(0, name.length - 5) + 'end'; |
| 10022 | name = name.substr(0, name.length - 6); |
| 10023 | } |
| 10024 | |
| 10025 | if (isNgProp || isNgEvent) { |
| 10026 | attrs[nName] = value; |
| 10027 | attrsMap[nName] = attr.name; |
| 10028 | |
| 10029 | if (isNgProp) { |
| 10030 | addPropertyDirective(node, directives, nName, name); |
| 10031 | } else { |
no test coverage detected