Skip to content

Commit

Permalink
Merge pull request #61 from canjs/fix-returning-callback
Browse files Browse the repository at this point in the history
Return registered callback
  • Loading branch information
imaustink committed Sep 29, 2017
2 parents 2c4569c + 546bc22 commit fdbff31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions can-view-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var attr = function (attributeName, attrHandler) {
//!steal-remove-start
requestedAttributes[attributeName] = true;
//!steal-remove-end

return cb;
}
};

Expand Down
8 changes: 8 additions & 0 deletions test/callbacks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,11 @@ if (System.env.indexOf('production') < 0) {
notOk(callbacks.tag('notexist'), "used default noop function")
});
}

QUnit.test("should return callback", function(){
var handler = function() {};
callbacks.attr('foo', handler);

var fooHandler = callbacks.attr('foo');
equal(fooHandler, handler, 'registered handler returned');
});

0 comments on commit fdbff31

Please sign in to comment.