* 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)
| 6194 | * @param {number=} maxPriority Max directive priority. |
| 6195 | */ |
| 6196 | function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { |
| 6197 | var nodeType = node.nodeType, |
| 6198 | attrsMap = attrs.$attr, |
| 6199 | match, |
| 6200 | nodeName, |
| 6201 | className; |
| 6202 | |
| 6203 | switch(nodeType) { |
| 6204 | case 1: /* Element */ |
| 6205 | |
| 6206 | nodeName = nodeName_(node).toLowerCase(); |
| 6207 | |
| 6208 | // use the node name: <directive> |
| 6209 | addDirective(directives, |
| 6210 | directiveNormalize(nodeName), 'E', maxPriority, ignoreDirective); |
| 6211 | |
| 6212 | // iterate over the attributes |
| 6213 | for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, |
| 6214 | j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { |
| 6215 | var attrStartName = false; |
| 6216 | var attrEndName = false; |
| 6217 | |
| 6218 | attr = nAttrs[j]; |
| 6219 | if (!msie || msie >= 8 || attr.specified) { |
| 6220 | name = attr.name; |
| 6221 | value = trim(attr.value); |
| 6222 | |
| 6223 | // support ngAttr attribute binding |
| 6224 | ngAttrName = directiveNormalize(name); |
| 6225 | if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { |
| 6226 | name = snake_case(ngAttrName.substr(6), '-'); |
| 6227 | } |
| 6228 | |
| 6229 | var directiveNName = ngAttrName.replace(/(Start|End)$/, ''); |
| 6230 | if (ngAttrName === directiveNName + 'Start') { |
| 6231 | attrStartName = name; |
| 6232 | attrEndName = name.substr(0, name.length - 5) + 'end'; |
| 6233 | name = name.substr(0, name.length - 6); |
| 6234 | } |
| 6235 | |
| 6236 | nName = directiveNormalize(name.toLowerCase()); |
| 6237 | attrsMap[nName] = name; |
| 6238 | if (isNgAttr || !attrs.hasOwnProperty(nName)) { |
| 6239 | attrs[nName] = value; |
| 6240 | if (getBooleanAttrName(node, nName)) { |
| 6241 | attrs[nName] = true; // presence means true |
| 6242 | } |
| 6243 | } |
| 6244 | addAttrInterpolateDirective(node, directives, value, nName); |
| 6245 | addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName, |
| 6246 | attrEndName); |
| 6247 | } |
| 6248 | } |
| 6249 | |
| 6250 | if (nodeName === 'input' && node.getAttribute('type') === 'hidden') { |
| 6251 | // Hidden input elements can have strange behaviour when navigating back to the page |
| 6252 | // This tells the browser not to try to cache and reinstate previous values |
| 6253 | node.setAttribute('autocomplete', 'off'); |
no test coverage detected