* When the element is replaced with HTML template then the new attributes * on the template need to be merged with the existing attributes in the DOM. * The desired effect is to have both of the attributes present. * * @param {object} dst destination attributes (original DOM)
(dst, src)
| 4455 | * @param {object} src source attributes (from the directive template) |
| 4456 | */ |
| 4457 | function mergeTemplateAttributes(dst, src) { |
| 4458 | var srcAttr = src.$attr, |
| 4459 | dstAttr = dst.$attr, |
| 4460 | $element = dst.$$element; |
| 4461 | |
| 4462 | // reapply the old attributes to the new element |
| 4463 | forEach(dst, function(value, key) { |
| 4464 | if (key.charAt(0) != '$') { |
| 4465 | if (src[key]) { |
| 4466 | value += (key === 'style' ? ';' : ' ') + src[key]; |
| 4467 | } |
| 4468 | dst.$set(key, value, true, srcAttr[key]); |
| 4469 | } |
| 4470 | }); |
| 4471 | |
| 4472 | // copy the new attributes on the old attrs object |
| 4473 | forEach(src, function(value, key) { |
| 4474 | if (key == 'class') { |
| 4475 | safeAddClass($element, value); |
| 4476 | dst['class'] = (dst['class'] ? dst['class'] + ' ' : '') + value; |
| 4477 | } else if (key == 'style') { |
| 4478 | $element.attr('style', $element.attr('style') + ';' + value); |
| 4479 | } else if (key.charAt(0) != '$' && !dst.hasOwnProperty(key)) { |
| 4480 | dst[key] = value; |
| 4481 | dstAttr[key] = srcAttr[key]; |
| 4482 | } |
| 4483 | }); |
| 4484 | } |
| 4485 | |
| 4486 | |
| 4487 | function compileTemplateUrl(directives, beforeTemplateNodeLinkFn, $compileNode, tAttrs, |
no test coverage detected