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

Function collectDirectives

lib/test/angular/1.6.7/angular.js:9314–9404  ·  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

9312 * @param {number=} maxPriority Max directive priority.
9313 */
9314 function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) {
9315 var nodeType = node.nodeType,
9316 attrsMap = attrs.$attr,
9317 match,
9318 nodeName,
9319 className;
9320
9321 switch (nodeType) {
9322 case NODE_TYPE_ELEMENT: /* Element */
9323
9324 nodeName = nodeName_(node);
9325
9326 // use the node name: <directive>
9327 addDirective(directives,
9328 directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective);
9329
9330 // iterate over the attributes
9331 for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,
9332 j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {
9333 var attrStartName = false;
9334 var attrEndName = false;
9335
9336 attr = nAttrs[j];
9337 name = attr.name;
9338 value = attr.value;
9339
9340 // support ngAttr attribute binding
9341 ngAttrName = directiveNormalize(name);
9342 isNgAttr = NG_ATTR_BINDING.test(ngAttrName);
9343 if (isNgAttr) {
9344 name = name.replace(PREFIX_REGEXP, '')
9345 .substr(8).replace(/_(.)/g, function(match, letter) {
9346 return letter.toUpperCase();
9347 });
9348 }
9349
9350 var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE);
9351 if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) {
9352 attrStartName = name;
9353 attrEndName = name.substr(0, name.length - 5) + 'end';
9354 name = name.substr(0, name.length - 6);
9355 }
9356
9357 nName = directiveNormalize(name.toLowerCase());
9358 attrsMap[nName] = name;
9359 if (isNgAttr || !attrs.hasOwnProperty(nName)) {
9360 attrs[nName] = value;
9361 if (getBooleanAttrName(node, nName)) {
9362 attrs[nName] = true; // presence means true
9363 }
9364 }
9365 addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
9366 addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
9367 attrEndName);
9368 }
9369
9370 if (nodeName === 'input' && node.getAttribute('type') === 'hidden') {
9371 // 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