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

Function collectDirectives

test/angular/1.7/angular.js:9909–10022  ·  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

9907 * @param {number=} maxPriority Max directive priority.
9908 */
9909 function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) {
9910 var nodeType = node.nodeType,
9911 attrsMap = attrs.$attr,
9912 match,
9913 nodeName,
9914 className;
9915
9916 switch (nodeType) {
9917 case NODE_TYPE_ELEMENT: /* Element */
9918
9919 nodeName = nodeName_(node);
9920
9921 // use the node name: <directive>
9922 addDirective(directives,
9923 directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective);
9924
9925 // iterate over the attributes
9926 for (var attr, name, nName, value, ngPrefixMatch, nAttrs = node.attributes,
9927 j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {
9928 var attrStartName = false;
9929 var attrEndName = false;
9930
9931 var isNgAttr = false, isNgProp = false, isNgEvent = false;
9932 var multiElementMatch;
9933
9934 attr = nAttrs[j];
9935 name = attr.name;
9936 value = attr.value;
9937
9938 nName = directiveNormalize(name.toLowerCase());
9939
9940 // Support ng-attr-*, ng-prop-* and ng-on-*
9941 if ((ngPrefixMatch = nName.match(NG_PREFIX_BINDING))) {
9942 isNgAttr = ngPrefixMatch[1] === 'Attr';
9943 isNgProp = ngPrefixMatch[1] === 'Prop';
9944 isNgEvent = ngPrefixMatch[1] === 'On';
9945
9946 // Normalize the non-prefixed name
9947 name = name.replace(PREFIX_REGEXP, '')
9948 .toLowerCase()
9949 .substr(4 + ngPrefixMatch[1].length).replace(/_(.)/g, function(match, letter) {
9950 return letter.toUpperCase();
9951 });
9952
9953 // Support *-start / *-end multi element directives
9954 } else if ((multiElementMatch = nName.match(MULTI_ELEMENT_DIR_RE)) && directiveIsMultiElement(multiElementMatch[1])) {
9955 attrStartName = name;
9956 attrEndName = name.substr(0, name.length - 5) + 'end';
9957 name = name.substr(0, name.length - 6);
9958 }
9959
9960 if (isNgProp || isNgEvent) {
9961 attrs[nName] = value;
9962 attrsMap[nName] = attr.name;
9963
9964 if (isNgProp) {
9965 addPropertyDirective(node, directives, nName, name);
9966 } else {

Callers 3

compileNodesFunction · 0.70
applyDirectivesToNodeFunction · 0.70
compileTemplateUrlFunction · 0.70

Calls 14

addPropertyDirectiveFunction · 0.85
addEventDirectiveFunction · 0.85
matchMethod · 0.80
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