Skip to content

Commit d524d10

Browse files
committed
Fix conflated prototype chains when extending.
1 parent 1674e71 commit d524d10

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/core.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) {
4848
}
4949

5050
// Create default initializer
51-
if (!subtype.hasOwnProperty('init')) {
51+
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
5252
subtype.init = function () {
5353
subtype.$super.init.apply(this, arguments);
5454
};

test/lib-base-test.js

+6
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ YUI.add('lib-base-test', function (Y) {
8181
this.data.obj.initArg = 'newValue';
8282

8383
Y.Assert.areNotEqual(this.data.obj.initArg, this.data.objClone.initArg);
84+
},
85+
86+
testCloneLeavesOriginalInitPrototypeUnchanged: function() {
87+
Y.Assert.areEqual(this.data.obj, this.data.obj.init.prototype);
88+
Y.Assert.areEqual(this.data.objClone, this.data.objClone.init.prototype);
89+
Y.Assert.areNotEqual(this.data.obj.init.prototype, this.data.objClone.init.prototype);
8490
}
8591
}));
8692
}, '$Rev$');

0 commit comments

Comments
 (0)