From 2bc7afd3bac5d8b22a876391ba8590568abc179e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 11 Oct 2011 22:52:30 -0700 Subject: fix(ng:class): ignore undefined or NaN classnames --- src/directives.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/directives.js b/src/directives.js index b1502f54..e5cb9044 100644 --- a/src/directives.js +++ b/src/directives.js @@ -557,8 +557,8 @@ function ngClass(selector) { return function(element) { this.$watch(expression, function(scope, newVal, oldVal) { if (selector(scope.$index)) { - element.removeClass(isArray(oldVal) ? oldVal.join(' ') : oldVal); - element.addClass(isArray(newVal) ? newVal.join(' ') : newVal); + if (oldVal) element.removeClass(isArray(oldVal) ? oldVal.join(' ') : oldVal); + if (newVal) element.addClass(isArray(newVal) ? newVal.join(' ') : newVal); } }); }; -- cgit v1.2.3