aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2011-07-19 16:07:25 -0700
committerIgor Minar2011-07-19 16:07:25 -0700
commit3ea2416f8083a21bf2f47f3381a66bf97e7f59e2 (patch)
treecd0d1d2990802732614f025c958bbec2eda34c25 /src
parent96361603322787117846e45573220c3cebdedb14 (diff)
downloadangular.js-3ea2416f8083a21bf2f47f3381a66bf97e7f59e2.tar.bz2
Revert "fix(ng:class): preserve classes added post compilation"
This reverts commit 2428907259fa80ec3b1b4bfd85ea20028a9f4fa5. We decided to revert this because it is not bullet proof. The issue is that we can't reliably have both angular and non-angular code in charge of the DOM. We could work around some issues here and there, but we can't do it reliably, so it's better not to support DOM manipulation that happens outside of angular. There is a good chance that once we integrate with MDVs our possition will change, but until then our position is that only angular or angular widgets/directives can change change DOM that was compiled.
Diffstat (limited to 'src')
-rw-r--r--src/directives.js25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/directives.js b/src/directives.js
index 6fc19eaf..d800aa80 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -565,25 +565,18 @@ angularDirective("ng:submit", function(expression, element) {
});
});
+
function ngClass(selector) {
return function(expression, element){
+ var existing = element[0].className + ' ';
return function(element){
- if(selector(this.$index)) {
- this.$watch(expression, function(newCls, oldCls) {
- var cls = element.attr('class');
- if (isArray(newCls)) newCls = newCls.join(' ');
- if (isArray(oldCls)) oldCls = oldCls.join(' ');
-
- // The time when newCls == oldCLs is when $watch just started
- if (newCls == oldCls) {
- cls += ' ' + newCls;
- } else {
- cls = cls.replace(' ' + oldCls, ' ' + newCls);
- }
-
- element.attr('class', cls);
- });
- }
+ this.$onEval(function(){
+ if (selector(this.$index)) {
+ var value = this.$eval(expression);
+ if (isArray(value)) value = value.join(' ');
+ element[0].className = trim(existing + value);
+ }
+ }, element);
};
};
}