From b1654f7034a5ab66eecdf6b3abd807e41f9a35bc Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 5 Nov 2014 14:04:24 -0800 Subject: [PATCH] [Framework] Fix partial constructor Fix the replicated behavior of the new operator in the partial constructor such that it accepts factory-style constructors (which will be the norm according to current code style standards.) WTD-518. --- platform/framework/src/register/PartialConstructor.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/framework/src/register/PartialConstructor.js b/platform/framework/src/register/PartialConstructor.js index 466851db50..91e9b39587 100644 --- a/platform/framework/src/register/PartialConstructor.js +++ b/platform/framework/src/register/PartialConstructor.js @@ -33,7 +33,11 @@ define( var other = Array.prototype.slice.call(arguments), instance = {}; - Constructor.apply(instance, dependencies.concat(other)); + // Mimic "new" behavior with apply. + instance = Constructor.apply( + instance, + dependencies.concat(other) + ) || instance; instance.prototype = Constructor.prototype; return instance;