Skip to content

Commit

Permalink
Change: Initialize returns always object instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pwlmaciejewski committed Oct 17, 2012
1 parent f956ba9 commit 3cfa500
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/unterproto.js
Expand Up @@ -21,8 +21,8 @@
},

init: function () {
var res = this.initialize.apply(this, arguments);
return res === undefined ? this : res;
this.initialize.apply(this, arguments);
return this;
},

initialize: function () {},
Expand Down
4 changes: 2 additions & 2 deletions test/testUnterproto.js
Expand Up @@ -71,15 +71,15 @@
assert.same(foo.bar, 'baz');
},

'return': function () {
'test if initialize returns something it should be ignored': function () {
var o = { foo: 'bar' };
var Foo = Proto.inherits({
initialize: function () {
return o;
}
});
var foo = Foo.instance();
assert.same(foo, o, 'If initialize() returns something it should be also returned by instance()');
refute.same(foo, o);
}
});
})();

0 comments on commit 3cfa500

Please sign in to comment.