Created
March 19, 2013 05:06
-
-
Save teramako/5193838 to your computer and use it in GitHub Desktop.
Object.setPrototypeOf の作成。Object.prototype.__proto__ が getter/setter として定義されていないと不可。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @see https://mail.mozilla.org/pipermail/es-discuss/2013-March/029259.html | |
* | |
* @name Object.setPrototypeOf | |
* @function | |
* @param {Object} aTarget | |
* @param {Object} aPrototype | |
*/ | |
(function() { | |
var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"); | |
if (typeof protoDesc.set === "function") { | |
Object.defineProperty(Object, "setPrototypeOf", { | |
value: Function.prototype.call.bind(protoDesc.set), | |
configurable :true, | |
writable: true | |
}); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment