Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Fix test on platforms that don't support Object.__proto__ (IE10)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 11, 2014
1 parent b35d794 commit e27162c
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions test/js/oop.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@
*/

function inherit(fn, prototype) {
var obj = Object.create(prototype);
// NOTE: On some platforms (IE10) __proto__ does not exist.
// In this case, we install it.
if (!Object.__proto__) {
obj.__proto__ = prototype;
}
obj.constructor = fn;
fn.prototype = obj;
return fn;
var obj = Object.create(prototype);
// NOTE: On some platforms (IE10) __proto__ does not exist.
// In this case, we install it.
if (!Object.__proto__) {
obj.__proto__ = prototype;
}
obj.constructor = fn;
fn.prototype = obj;
return fn;
}

function instance(fn) {
var obj = new fn();
if (!Object.__proto__) {
obj.__proto__ = fn.prototype;
}
return obj;
}

suite('oop', function() {
var assert = chai.assert;
Expand Down Expand Up @@ -49,7 +57,7 @@ suite('oop', function() {
this.log(' subsub');
};
//
var subSub = new SubSub();
var subSub = instance(SubSub);
subSub.say();
assert.equal(subSub.msg, 'sub subsub');
});
Expand Down

0 comments on commit e27162c

Please sign in to comment.