Skip to content

Commit

Permalink
Fix to ensure that constructor returned prototypes are not lost
Browse files Browse the repository at this point in the history
  • Loading branch information
Damon Oehlman committed Mar 17, 2012
1 parent 6784c62 commit 8a1023b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions registry.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ var wildcard = require('wildcard'),
// if the new object has successfully been created, and is of type object
// then assign the prototype
if (typeof newObject == 'object') {
// copy any methods from the object prototype into this prototype
if (newObject.__proto__ !== this._prototype) {
for (var key in newObject.__proto__) {
this._prototype[key] = newObject.__proto__[key];
}
}

// retarget the new object prototype
newObject.__proto__ = this._prototype;
}

Expand Down
8 changes: 8 additions & 0 deletions registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
// if the new object has successfully been created, and is of type object
// then assign the prototype
if (typeof newObject == 'object') {
// copy any methods from the object prototype into this prototype
if (newObject.__proto__ !== this._prototype) {
for (var key in newObject.__proto__) {
this._prototype[key] = newObject.__proto__[key];
}
}

// retarget the new object prototype
newObject.__proto__ = this._prototype;
}

Expand Down
8 changes: 8 additions & 0 deletions src/core/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ RegistryDefinition.prototype = {
// if the new object has successfully been created, and is of type object
// then assign the prototype
if (typeof newObject == 'object') {
// copy any methods from the object prototype into this prototype
if (newObject.__proto__ !== this._prototype) {
for (var key in newObject.__proto__) {
this._prototype[key] = newObject.__proto__[key];
}
}

// retarget the new object prototype
newObject.__proto__ = this._prototype;
}

Expand Down

0 comments on commit 8a1023b

Please sign in to comment.