Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Use proper Object.create-style inheritance in browsers.

Domenic Denicola0b3a527a49a6
diff --git a/support/compile.js b/support/compile.js
index ca13d769..a8e047dd 100644
--- a/support/compile.js
+++ b/support/compile.js
@@ -58,7 +58,9 @@ function parseRequires(js) {
function parseInheritance(js) {
return js
.replace(/^ *(\w+)\.prototype\.__proto__ * = *(\w+)\.prototype *;?/gm, function(_, child, parent){
- return child + '.prototype = new ' + parent + ';\n'
+ return 'function F(){};\n'
+ + 'F.prototype = ' + parent + '.prototype;\n'
+ + child + '.prototype = new F;\n'
+ child + '.prototype.constructor = '+ child + ';\n';
});
}