Skip to content

Commit

Permalink
Fix conflated prototype chains when extending.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkaminski committed Oct 4, 2016
1 parent 1674e71 commit d524d10
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 d524d10

Please sign in to comment.