* 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)
| 7176 | * @param {number=} maxPriority Max directive priority. |
| 7177 | */ |
| 7178 | function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { |
| 7179 | var nodeType = node.nodeType, |
| 7180 | attrsMap = attrs.$attr, |
| 7181 | match, |
| 7182 | className; |
| 7183 | |
| 7184 | switch (nodeType) { |
| 7185 | case NODE_TYPE_ELEMENT: /* Element */ |
| 7186 | // use the node name: <directive> |
| 7187 | addDirective(directives, |
| 7188 | directiveNormalize(nodeName_(node)), 'E', maxPriority, ignoreDirective); |
| 7189 | |
| 7190 | // iterate over the attributes |
| 7191 | for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, |
| 7192 | j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { |
| 7193 | var attrStartName = false; |
| 7194 | var attrEndName = false; |
| 7195 | |
| 7196 | attr = nAttrs[j]; |
| 7197 | name = attr.name; |
| 7198 | value = trim(attr.value); |
| 7199 | |
| 7200 | // support ngAttr attribute binding |
| 7201 | ngAttrName = directiveNormalize(name); |
| 7202 | if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { |
| 7203 | name = name.replace(PREFIX_REGEXP, '') |
| 7204 | .substr(8).replace(/_(.)/g, function(match, letter) { |
| 7205 | return letter.toUpperCase(); |
| 7206 | }); |
| 7207 | } |
| 7208 | |
| 7209 | var directiveNName = ngAttrName.replace(/(Start|End)$/, ''); |
| 7210 | if (directiveIsMultiElement(directiveNName)) { |
| 7211 | if (ngAttrName === directiveNName + 'Start') { |
| 7212 | attrStartName = name; |
| 7213 | attrEndName = name.substr(0, name.length - 5) + 'end'; |
| 7214 | name = name.substr(0, name.length - 6); |
| 7215 | } |
| 7216 | } |
| 7217 | |
| 7218 | nName = directiveNormalize(name.toLowerCase()); |
| 7219 | attrsMap[nName] = name; |
| 7220 | if (isNgAttr || !attrs.hasOwnProperty(nName)) { |
| 7221 | attrs[nName] = value; |
| 7222 | if (getBooleanAttrName(node, nName)) { |
| 7223 | attrs[nName] = true; // presence means true |
| 7224 | } |
| 7225 | } |
| 7226 | addAttrInterpolateDirective(node, directives, value, nName, isNgAttr); |
| 7227 | addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName, |
| 7228 | attrEndName); |
| 7229 | } |
| 7230 | |
| 7231 | // use class as directive |
| 7232 | className = node.className; |
| 7233 | if (isObject(className)) { |
| 7234 | // Maybe SVGAnimatedString |
| 7235 | className = className.animVal; |
no test coverage detected