MCPcopy
hub / github.com/angular-ui/ui-grid / collectDirectives

Function collectDirectives

lib/test/angular/1.8.0/angular.js:9974–10087  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 {

Callers 3

compileNodesFunction · 0.70
applyDirectivesToNodeFunction · 0.70
compileTemplateUrlFunction · 0.70

Calls 13

addPropertyDirectiveFunction · 0.85
addEventDirectiveFunction · 0.85
nodeName_Function · 0.70
addDirectiveFunction · 0.70
directiveNormalizeFunction · 0.70
directiveIsMultiElementFunction · 0.70
getBooleanAttrNameFunction · 0.70
isObjectFunction · 0.70
isStringFunction · 0.70
trimFunction · 0.70

Tested by

no test coverage detected