diff --git a/CHANGELOG b/CHANGELOG index 0b5f84d..c5ba202 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Make Fuseboxed constructor's prototype values of the OBJECT__PROTO__ branch conform to ECMA specifications. [jddalton] + * Add sandboxed Boolean constructor to Fusebox. [jddalton] * Add a lot of comments to Fuse.Fusebox() and cleanup its codebase. [jddalton] diff --git a/src/lang/fusebox.js b/src/lang/fusebox.js index 2546f92..155d7c2 100644 --- a/src/lang/fusebox.js +++ b/src/lang/fusebox.js @@ -88,8 +88,8 @@ throw new Error('Fusebox failed to create a sandbox by iframe.'); } - result = Fuse[expando]; - delete Fuse[expando]; + result = global.Fuse[expando]; + delete global.Fuse[expando]; cache.push(iframe); return result; @@ -192,14 +192,15 @@ return result; }; - // make native wrappers inherit from regular natives - Array.prototype['__proto__'] = __Array.prototype; - Date.prototype['__proto__'] = __Date.prototype; - Function.prototype['__proto__'] = __Function.prototype; - Number.prototype['__proto__'] = __Number.prototype; + // make prototype values conform to ECMA spec and inherit from regular natives Object.prototype['__proto__'] = __Object.prototype; - RegExp.prototype['__proto__'] = __RegExp.prototype; - String.prototype['__proto__'] = __String.prototype; + (Array.prototype = [ ])['__proto__'] = __Array.prototype; + (Boolean.prototype = new __Boolean)['__proto__'] = __Boolean.prototype; + (Date.prototype = new __Date)['__proto__'] = __Date.prototype; + (Function.prototype = new __Function)['__proto__'] = __Function.prototype; + (Number.prototype = new __Number)['__proto__'] = __Number.prototype; + (RegExp.prototype = new __RegExp)['__proto__'] = __RegExp.prototype; + (String.prototype = new __String)['__proto__'] = __String.prototype; } else { Array = function Array(length) {