This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ function classDirective(name, selector) {
97
97
98
98
function arrayClasses ( classVal ) {
99
99
if ( isArray ( classVal ) ) {
100
- return classVal ;
100
+ return classVal . join ( ' ' ) . split ( ' ' ) ;
101
101
} else if ( isString ( classVal ) ) {
102
102
return classVal . split ( ' ' ) ;
103
103
} else if ( isObject ( classVal ) ) {
Original file line number Diff line number Diff line change @@ -88,6 +88,16 @@ describe('ngClass', function() {
88
88
} ) ) ;
89
89
90
90
91
+ it ( 'should support adding multiple classes via a space delimited string inside an array' , inject ( function ( $rootScope , $compile ) {
92
+ element = $compile ( '<div class="existing" ng-class="[\'A B\', \'C\']"></div>' ) ( $rootScope ) ;
93
+ $rootScope . $digest ( ) ;
94
+ expect ( element . hasClass ( 'existing' ) ) . toBeTruthy ( ) ;
95
+ expect ( element . hasClass ( 'A' ) ) . toBeTruthy ( ) ;
96
+ expect ( element . hasClass ( 'B' ) ) . toBeTruthy ( ) ;
97
+ expect ( element . hasClass ( 'C' ) ) . toBeTruthy ( ) ;
98
+ } ) ) ;
99
+
100
+
91
101
it ( 'should preserve class added post compilation with pre-existing classes' , inject ( function ( $rootScope , $compile ) {
92
102
element = $compile ( '<div class="existing" ng-class="dynClass"></div>' ) ( $rootScope ) ;
93
103
$rootScope . dynClass = 'A' ;
You can’t perform that action at this time.
0 commit comments