File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1005,11 +1005,12 @@ lib.templateString = function(string) {
1005
1005
var obj , value , i ;
1006
1006
for ( i = 1 ; i < args . length ; i ++ ) {
1007
1007
obj = args [ i ] ;
1008
- if ( SIMPLE_PROPERTY_REGEX . test ( key ) ) {
1009
- if ( obj . hasOwnProperty ( key ) ) {
1010
- value = obj [ key ] ;
1011
- }
1012
- } else {
1008
+ if ( obj . hasOwnProperty ( key ) ) {
1009
+ value = obj [ key ] ;
1010
+ break ;
1011
+ }
1012
+
1013
+ if ( ! SIMPLE_PROPERTY_REGEX . test ( key ) ) {
1013
1014
// getterCache[key] = getterCache[key] || lib.nestedProperty(obj, key).get;
1014
1015
// value = getterCache[key]();
1015
1016
value = getterCache [ key ] || lib . nestedProperty ( obj , key ) . get ( ) ;
Original file line number Diff line number Diff line change @@ -2124,6 +2124,10 @@ describe('Test lib.js:', function() {
2124
2124
expect ( Lib . templateString ( 'foo %{bar}' , { bar : 'baz' } ) ) . toEqual ( 'foo baz' ) ;
2125
2125
} ) ;
2126
2126
2127
+ it ( 'evaluates attributes with a dot in their name' , function ( ) {
2128
+ expect ( Lib . templateString ( '%{marker.size}' , { 'marker.size' : 12 } , { marker : { size : 14 } } ) ) . toEqual ( '12' ) ;
2129
+ } ) ;
2130
+
2127
2131
it ( 'evaluates nested properties' , function ( ) {
2128
2132
expect ( Lib . templateString ( 'foo %{bar.baz}' , { bar : { baz : 'asdf' } } ) ) . toEqual ( 'foo asdf' ) ;
2129
2133
} ) ;
@@ -2144,7 +2148,7 @@ describe('Test lib.js:', function() {
2144
2148
expect ( Lib . templateString ( 'foo %{} %{}' , { } ) ) . toEqual ( 'foo ' ) ;
2145
2149
} ) ;
2146
2150
2147
- it ( 'find the first object with a given key' , function ( ) {
2151
+ it ( 'uses the value from the first object with the specified key' , function ( ) {
2148
2152
var obj1 = { a : 'first' } , obj2 = { a : 'second' , foo : { bar : 'bar' } } ;
2149
2153
2150
2154
// Simple key
You can’t perform that action at this time.
0 commit comments