MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / collectDirectives

Function collectDirectives

lib/test/angular/1.4.3/angular.js:7580–7678  ·  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

7578 * @param {number=} maxPriority Max directive priority.
7579 */
7580 function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) {
7581 var nodeType = node.nodeType,
7582 attrsMap = attrs.$attr,
7583 match,
7584 className;
7585
7586 switch (nodeType) {
7587 case NODE_TYPE_ELEMENT: /* Element */
7588 // use the node name: <directive>
7589 addDirective(directives,
7590 directiveNormalize(nodeName_(node)), 'E', maxPriority, ignoreDirective);
7591
7592 // iterate over the attributes
7593 for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,
7594 j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {
7595 var attrStartName = false;
7596 var attrEndName = false;
7597
7598 attr = nAttrs[j];
7599 name = attr.name;
7600 value = trim(attr.value);
7601
7602 // support ngAttr attribute binding
7603 ngAttrName = directiveNormalize(name);
7604 if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
7605 name = name.replace(PREFIX_REGEXP, '')
7606 .substr(8).replace(/_(.)/g, function(match, letter) {
7607 return letter.toUpperCase();
7608 });
7609 }
7610
7611 var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
7612 if (directiveIsMultiElement(directiveNName)) {
7613 if (ngAttrName === directiveNName + 'Start') {
7614 attrStartName = name;
7615 attrEndName = name.substr(0, name.length - 5) + 'end';
7616 name = name.substr(0, name.length - 6);
7617 }
7618 }
7619
7620 nName = directiveNormalize(name.toLowerCase());
7621 attrsMap[nName] = name;
7622 if (isNgAttr || !attrs.hasOwnProperty(nName)) {
7623 attrs[nName] = value;
7624 if (getBooleanAttrName(node, nName)) {
7625 attrs[nName] = true; // presence means true
7626 }
7627 }
7628 addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
7629 addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
7630 attrEndName);
7631 }
7632
7633 // use class as directive
7634 className = node.className;
7635 if (isObject(className)) {
7636 // Maybe SVGAnimatedString
7637 className = className.animVal;

Callers 3

compileNodesFunction · 0.70
applyDirectivesToNodeFunction · 0.70
compileTemplateUrlFunction · 0.70

Calls 10

addDirectiveFunction · 0.70
directiveNormalizeFunction · 0.70
nodeName_Function · 0.70
trimFunction · 0.70
directiveIsMultiElementFunction · 0.70
getBooleanAttrNameFunction · 0.70
isObjectFunction · 0.70
isStringFunction · 0.70

Tested by

no test coverage detected