aboutsummaryrefslogtreecommitdiffstats
path: root/src/ngAnimate/animate.js
diff options
context:
space:
mode:
authorMatias Niemelä2014-01-02 14:52:49 -0500
committerMatias Niemelä2014-01-14 13:18:50 -0500
commit524650a40ed20f01571e5466475749874ee67288 (patch)
tree04f72623df7c18002fb2ae5021a8a43fc838bd28 /src/ngAnimate/animate.js
parent02a45826f12842a5eec07989264abbe42b381a7c (diff)
downloadangular.js-524650a40ed20f01571e5466475749874ee67288.tar.bz2
fix($animate): avoid accidentally matching substrings when resolving the presence of className tokens
Diffstat (limited to 'src/ngAnimate/animate.js')
-rw-r--r--src/ngAnimate/animate.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js
index 64ed3029..62f6381d 100644
--- a/src/ngAnimate/animate.js
+++ b/src/ngAnimate/animate.js
@@ -647,10 +647,11 @@ angular.module('ngAnimate', ['ng'])
return;
}
+ var ONE_SPACE = ' ';
//this value will be searched for class-based CSS className lookup. Therefore,
//we prefix and suffix the current className value with spaces to avoid substring
//lookups of className tokens
- var futureClassName = ' ' + currentClassName + ' ';
+ var futureClassName = ONE_SPACE + currentClassName + ONE_SPACE;
if(ngAnimateState.running) {
//if an animation is currently running on the element then lets take the steps
//to cancel that animation and fire any required callbacks
@@ -671,8 +672,8 @@ angular.module('ngAnimate', ['ng'])
//will be invalid. Therefore the same string manipulation that would occur within the
//DOM operation will be performed below so that the class comparison is valid...
futureClassName = ngAnimateState.event == 'removeClass' ?
- futureClassName.replace(ngAnimateState.className, '') :
- futureClassName + ngAnimateState.className + ' ';
+ futureClassName.replace(ONE_SPACE + ngAnimateState.className + ONE_SPACE, ONE_SPACE) :
+ futureClassName + ngAnimateState.className + ONE_SPACE;
}
}
@@ -680,7 +681,7 @@ angular.module('ngAnimate', ['ng'])
//(on addClass) or doesn't contain (on removeClass) the className being animated.
//The reason why this is being called after the previous animations are cancelled
//is so that the CSS classes present on the element can be properly examined.
- var classNameToken = ' ' + className + ' ';
+ var classNameToken = ONE_SPACE + className + ONE_SPACE;
if((animationEvent == 'addClass' && futureClassName.indexOf(classNameToken) >= 0) ||
(animationEvent == 'removeClass' && futureClassName.indexOf(classNameToken) == -1)) {
fireDOMOperation();