Skip to content

Commit

Permalink
Merge pull request #341 from schovi/can-sub-remove-fix
Browse files Browse the repository at this point in the history
can.sub fix remove param. Allow only to remove properties + tests
  • Loading branch information
daffl committed Apr 16, 2013
2 parents ff1d361 + 3367817 commit e7e335b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion util/string/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ steal('can/util',function(can) {
obs.push( str.replace( strReplacer, function( whole, inside ) {

// Convert inside to type.
var ob = can.getObject( inside, data, remove === undefined? remove : !remove );
var ob = can.getObject( inside, data, remove === true ? false : undefined );

if(ob === undefined) {
obs = null;
Expand Down
8 changes: 8 additions & 0 deletions util/string/string_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ test("String.underscore", function(){
equals(can.underscore("Foo.Bar.ZarDar"),"foo.bar.zar_dar")
});

test("can.sub remove", function(){
var obj = {a: 'a'}
equals(can.sub("{a}", obj, false), "a");
deepEqual(obj, {a: 'a'});

equals(can.sub("{a}", obj, true), "a");
deepEqual(obj, {});
});

test("can.getObject", function(){
var obj = can.getObject("foo", [{a: 1}, {foo: 'bar'}]);
Expand Down

0 comments on commit e7e335b

Please sign in to comment.