* 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)
| 9383 | * @param {number=} maxPriority Max directive priority. |
| 9384 | */ |
| 9385 | function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { |
| 9386 | var nodeType = node.nodeType, |
| 9387 | attrsMap = attrs.$attr, |
| 9388 | match, |
| 9389 | nodeName, |
| 9390 | className; |
| 9391 | |
| 9392 | switch (nodeType) { |
| 9393 | case NODE_TYPE_ELEMENT: /* Element */ |
| 9394 | |
| 9395 | nodeName = nodeName_(node); |
| 9396 | |
| 9397 | // use the node name: <directive> |
| 9398 | addDirective(directives, |
| 9399 | directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective); |
| 9400 | |
| 9401 | // iterate over the attributes |
| 9402 | for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, |
| 9403 | j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { |
| 9404 | var attrStartName = false; |
| 9405 | var attrEndName = false; |
| 9406 | |
| 9407 | attr = nAttrs[j]; |
| 9408 | name = attr.name; |
| 9409 | value = attr.value; |
| 9410 | |
| 9411 | // support ngAttr attribute binding |
| 9412 | ngAttrName = directiveNormalize(name); |
| 9413 | isNgAttr = NG_ATTR_BINDING.test(ngAttrName); |
| 9414 | if (isNgAttr) { |
| 9415 | name = name.replace(PREFIX_REGEXP, '') |
| 9416 | .substr(8).replace(/_(.)/g, function(match, letter) { |
| 9417 | return letter.toUpperCase(); |
| 9418 | }); |
| 9419 | } |
| 9420 | |
| 9421 | var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE); |
| 9422 | if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) { |
| 9423 | attrStartName = name; |
| 9424 | attrEndName = name.substr(0, name.length - 5) + 'end'; |
| 9425 | name = name.substr(0, name.length - 6); |
| 9426 | } |
| 9427 | |
| 9428 | nName = directiveNormalize(name.toLowerCase()); |
| 9429 | attrsMap[nName] = name; |
| 9430 | if (isNgAttr || !attrs.hasOwnProperty(nName)) { |
| 9431 | attrs[nName] = value; |
| 9432 | if (getBooleanAttrName(node, nName)) { |
| 9433 | attrs[nName] = true; // presence means true |
| 9434 | } |
| 9435 | } |
| 9436 | addAttrInterpolateDirective(node, directives, value, nName, isNgAttr); |
| 9437 | addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName, |
| 9438 | attrEndName); |
| 9439 | } |
| 9440 | |
| 9441 | if (nodeName === 'input' && node.getAttribute('type') === 'hidden') { |
| 9442 | // Hidden input elements can have strange behaviour when navigating back to the page |
no test coverage detected