This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 360
360
var value = validateAttributeValue ( className , newValue || "" ) ;
361
361
if ( angular . isDefined ( value ) ) {
362
362
if ( lastClass ) element . removeClass ( lastClass ) ;
363
- lastClass = ! value ? className : className + "-" + value . replace ( WHITESPACE , "-" ) ;
363
+ lastClass = ! value ? className : className + "-" + value . trim ( ) . replace ( WHITESPACE , "-" ) ;
364
364
element . addClass ( lastClass ) ;
365
365
}
366
366
} ;
407
407
* fallback value
408
408
*/
409
409
function validateAttributeValue ( className , value , updateFn ) {
410
- var origValue = value ;
410
+ var origValue ;
411
411
412
412
if ( ! needsInterpolation ( value ) ) {
413
413
switch ( className . replace ( SUFFIXES , "" ) ) {
452
452
}
453
453
}
454
454
455
- return value ;
455
+ return value ? value . trim ( ) : "" ;
456
456
}
457
457
458
458
/**
479
479
480
480
function getNormalizedAttrValue ( className , attrs , defaultVal ) {
481
481
var normalizedAttr = attrs . $normalize ( className ) ;
482
- return attrs [ normalizedAttr ] ? attrs [ normalizedAttr ] . replace ( WHITESPACE , "-" ) : defaultVal || null ;
482
+ return attrs [ normalizedAttr ] ? attrs [ normalizedAttr ] . trim ( ) . replace ( WHITESPACE , "-" ) : defaultVal || null ;
483
483
}
484
484
485
485
function findIn ( item , list , replaceWith ) {
Original file line number Diff line number Diff line change @@ -132,6 +132,13 @@ describe("Layout API ", function() {
132
132
expect ( element . hasClass ( 'flex-gt-sm' ) ) . toBeTruthy ( ) ;
133
133
} ) ;
134
134
135
+ it ( 'should support untrimmed attribute values with spaces' , inject ( function ( $rootScope , $compile ) {
136
+ var scope = pageScope ;
137
+ var element = angular . element ( $compile ( '<div flex-gt-xs="50 "></div>' ) ( scope ) ) ;
138
+
139
+ expect ( element . hasClass ( 'flex-gt-xs-50' ) ) . toBe ( true ) ;
140
+ } ) ) ;
141
+
135
142
it ( 'should observe the attribute value and update the layout class(es)' , inject ( function ( $rootScope , $compile ) {
136
143
var scope = pageScope ;
137
144
var element = angular . element ( $compile ( '<div flex-gt-md="{{size}}"></div>' ) ( scope ) ) ;
You can’t perform that action at this time.
0 commit comments