Skip to content

Commit

Permalink
Merge pull request brix#66 from pkaminski/prototype-chains
Browse files Browse the repository at this point in the history
Fix conflated prototype chains when extending.
  • Loading branch information
evanvosberg authored Oct 7, 2016
2 parents 1674e71 + d524d10 commit 0654a6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
}

// Create default initializer
if (!subtype.hasOwnProperty('init')) {
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
subtype.init = function () {
subtype.$super.init.apply(this, arguments);
};
Expand Down
6 changes: 6 additions & 0 deletions test/lib-base-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ YUI.add('lib-base-test', function (Y) {
this.data.obj.initArg = 'newValue';

Y.Assert.areNotEqual(this.data.obj.initArg, this.data.objClone.initArg);
},

testCloneLeavesOriginalInitPrototypeUnchanged: function() {
Y.Assert.areEqual(this.data.obj, this.data.obj.init.prototype);
Y.Assert.areEqual(this.data.objClone, this.data.objClone.init.prototype);
Y.Assert.areNotEqual(this.data.obj.init.prototype, this.data.objClone.init.prototype);
}
}));
}, '$Rev$');

0 comments on commit 0654a6f

Please sign in to comment.