MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / collectDirectives

Function collectDirectives

web/static/bower_components/angular/angular.js:7719–7817  ·  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

7717 * @param {number=} maxPriority Max directive priority.
7718 */
7719 function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) {
7720 var nodeType = node.nodeType,
7721 attrsMap = attrs.$attr,
7722 match,
7723 className;
7724
7725 switch (nodeType) {
7726 case NODE_TYPE_ELEMENT: /* Element */
7727 // use the node name: <directive>
7728 addDirective(directives,
7729 directiveNormalize(nodeName_(node)), 'E', maxPriority, ignoreDirective);
7730
7731 // iterate over the attributes
7732 for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,
7733 j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {
7734 var attrStartName = false;
7735 var attrEndName = false;
7736
7737 attr = nAttrs[j];
7738 name = attr.name;
7739 value = trim(attr.value);
7740
7741 // support ngAttr attribute binding
7742 ngAttrName = directiveNormalize(name);
7743 if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
7744 name = name.replace(PREFIX_REGEXP, '')
7745 .substr(8).replace(/_(.)/g, function(match, letter) {
7746 return letter.toUpperCase();
7747 });
7748 }
7749
7750 var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
7751 if (directiveIsMultiElement(directiveNName)) {
7752 if (ngAttrName === directiveNName + 'Start') {
7753 attrStartName = name;
7754 attrEndName = name.substr(0, name.length - 5) + 'end';
7755 name = name.substr(0, name.length - 6);
7756 }
7757 }
7758
7759 nName = directiveNormalize(name.toLowerCase());
7760 attrsMap[nName] = name;
7761 if (isNgAttr || !attrs.hasOwnProperty(nName)) {
7762 attrs[nName] = value;
7763 if (getBooleanAttrName(node, nName)) {
7764 attrs[nName] = true; // presence means true
7765 }
7766 }
7767 addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);
7768 addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,
7769 attrEndName);
7770 }
7771
7772 // use class as directive
7773 className = node.className;
7774 if (isObject(className)) {
7775 // Maybe SVGAnimatedString
7776 className = className.animVal;

Callers 3

compileNodesFunction · 0.85
applyDirectivesToNodeFunction · 0.85
compileTemplateUrlFunction · 0.85

Calls 10

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

Tested by

no test coverage detected