default constructor should return parent value

I came across this issue with a class that caches instances when
they are firste created. Subsequent calls to the constructor will
return the cached instance if available. This relies on a feature
of JavaScript described here:

http://bclary.com/2004/11/07/#a-13.2.2

Note Step 7 in the reference document. By not returning the value
from the default constructor, subclasses of Backbone classes that
rely on this feature will break.
This commit is contained in:
Chris Davaz
2012-12-14 16:07:27 -08:00
parent 523fb81779
commit 3666613020

View File

@@ -1499,7 +1499,7 @@
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){ parent.apply(this, arguments); };
child = function(){ return parent.apply(this, arguments); };
}
// Add static properties to the constructor function, if supplied.