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

Function collectDirectives

lib/test/angular/1.5.0/angular.js:8275–8371  ·  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

8273 * @param {number=} maxPriority Max directive priority.
8274 */
8275 function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) {
8276 var nodeType = node.nodeType,
8277 attrsMap = attrs.$attr,
8278 match,
8279 className;
8280
8281 switch (nodeType) {
8282 case NODE_TYPE_ELEMENT: /* Element */
8283 // use the node name: <directive>
8284 addDirective(directives,
8285 directiveNormalize(nodeName_(node)), 'E', maxPriority, ignoreDirective);
8286
8287 // iterate over the attributes
8288 for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,
8289 j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {
8290 var attrStartName = false;
8291 var attrEndName = false;
8292
8293 attr = nAttrs[j];
8294 name = attr.name;
8295 value = trim(attr.value);
8296
8297 // support ngAttr attribute binding
8298 ngAttrName = directiveNormalize(name);
8299 if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
8300 name = name.replace(PREFIX_REGEXP, '')
8301 .substr(8).replace(/_(.)/g, function(match, letter) {
8302 return letter.toUpperCase();
8303 });
8304 }
8305
8306 var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE);
8307 if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) {
8308 attrStartName = name;
8309 attrEndName = name.substr(0, name.length - 5) + 'end';
8310 name = name.substr(0, name.length - 6);
8311 }
8312
8313 nName = directiveNormalize(name.toLowerCase());
8314 attrsMap[nName] = name;
8315 if (isNgAttr || !attrs.hasOwnProperty(nName)) {
8316 attrs[nName] = value;
8317 if (getBooleanAttrName(node, nName)) {
8318 attrs[nName] = true; // presence means true
8319 }
8320 }
8321 addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
8322 addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
8323 attrEndName);
8324 }
8325
8326 // use class as directive
8327 className = node.className;
8328 if (isObject(className)) {
8329 // Maybe SVGAnimatedString
8330 className = className.animVal;
8331 }
8332 if (isString(className) && className !== '') {

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