From 6b8bbe4d90640542eed5607a8c91f6b977b1d6c0 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Thu, 14 Nov 2013 23:45:22 -0500 Subject: fix(ngClass): ensure that ngClass only adds/removes the changed classes ngClass works by removing all the former classes and then adding all the new classes to the element during each watch change operation. This may cause transition animations to never render. The ngClass directive will now only add and remove the classes that change during each watch operation. Closes #4960 Closes #4944 --- src/ng/compile.js | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'src/ng/compile.js') diff --git a/src/ng/compile.js b/src/ng/compile.js index 4d83f379..ce3d0514 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -688,8 +688,8 @@ function $CompileProvider($provide) { if(key == 'class') { value = value || ''; var current = this.$$element.attr('class') || ''; - this.$removeClass(tokenDifference(current, value).join(' ')); - this.$addClass(tokenDifference(value, current).join(' ')); + this.$removeClass(tokenDifference(current, value)); + this.$addClass(tokenDifference(value, current)); } else { var booleanKey = getBooleanAttrName(this.$$element[0], key), normalizedVal, @@ -747,22 +747,6 @@ function $CompileProvider($provide) { $exceptionHandler(e); } }); - - function tokenDifference(str1, str2) { - var values = [], - tokens1 = str1.split(/\s+/), - tokens2 = str2.split(/\s+/); - - outer: - for(var i=0;i