MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / collectDirectives

Function collectDirectives

lib/test/angular/1.7.0/angular.js:9424–9514  ·  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

9422 * @param {number=} maxPriority Max directive priority.
9423 */
9424 function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) {
9425 var nodeType = node.nodeType,
9426 attrsMap = attrs.$attr,
9427 match,
9428 nodeName,
9429 className;
9430
9431 switch (nodeType) {
9432 case NODE_TYPE_ELEMENT: /* Element */
9433
9434 nodeName = nodeName_(node);
9435
9436 // use the node name: <directive>
9437 addDirective(directives,
9438 directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective);
9439
9440 // iterate over the attributes
9441 for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,
9442 j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {
9443 var attrStartName = false;
9444 var attrEndName = false;
9445
9446 attr = nAttrs[j];
9447 name = attr.name;
9448 value = attr.value;
9449
9450 // support ngAttr attribute binding
9451 ngAttrName = directiveNormalize(name);
9452 isNgAttr = NG_ATTR_BINDING.test(ngAttrName);
9453 if (isNgAttr) {
9454 name = name.replace(PREFIX_REGEXP, '')
9455 .substr(8).replace(/_(.)/g, function(match, letter) {
9456 return letter.toUpperCase();
9457 });
9458 }
9459
9460 var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE);
9461 if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) {
9462 attrStartName = name;
9463 attrEndName = name.substr(0, name.length - 5) + 'end';
9464 name = name.substr(0, name.length - 6);
9465 }
9466
9467 nName = directiveNormalize(name.toLowerCase());
9468 attrsMap[nName] = name;
9469 if (isNgAttr || !attrs.hasOwnProperty(nName)) {
9470 attrs[nName] = value;
9471 if (getBooleanAttrName(node, nName)) {
9472 attrs[nName] = true; // presence means true
9473 }
9474 }
9475 addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
9476 addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
9477 attrEndName);
9478 }
9479
9480 if (nodeName === 'input' && node.getAttribute('type') === 'hidden') {
9481 // Hidden input elements can have strange behaviour when navigating back to the page

Callers 3

compileNodesFunction · 0.70
applyDirectivesToNodeFunction · 0.70
compileTemplateUrlFunction · 0.70

Calls 11

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
collectCommentDirectivesFunction · 0.70

Tested by

no test coverage detected