From fb99b539b4d851773b43f1564f7032adb157c0db Mon Sep 17 00:00:00 2001 From: Max Martinsson Date: Wed, 6 Jun 2012 16:23:07 +0200 Subject: fix($compile): correctly merge class attr for replace directives Merging of interpolated class attribute from directive template with replace:true works Closes #1006 --- src/ng/compile.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ng/compile.js') diff --git a/src/ng/compile.js b/src/ng/compile.js index e1aba35b..1dbb63be 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -865,6 +865,7 @@ function $CompileProvider($provide) { var srcAttr = src.$attr, dstAttr = dst.$attr, $element = dst.$$element; + // reapply the old attributes to the new element forEach(dst, function(value, key) { if (key.charAt(0) != '$') { @@ -874,10 +875,12 @@ function $CompileProvider($provide) { dst.$set(key, value, true, srcAttr[key]); } }); + // copy the new attributes on the old attrs object forEach(src, function(value, key) { if (key == 'class') { safeAddClass($element, value); + dst['class'] = (dst['class'] ? dst['class'] + ' ' : '') + value; } else if (key == 'style') { $element.attr('style', $element.attr('style') + ';' + value); } else if (key.charAt(0) != '$' && !dst.hasOwnProperty(key)) { -- cgit v1.2.3