-
-
Save leecade/4401057 to your computer and use it in GitHub Desktop.
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
| /*!(C) WebReflection *//** @license Mit Style */ | |
| // inspired by https://gist.github.com/4395291 | |
| this.inherit || (this.inherit = function(create){ | |
| if (!create) { | |
| if ({__proto__:null} instanceof Object) { | |
| for (var | |
| Null = function Null() {}, | |
| doc = document, | |
| html = doc.documentElement, | |
| iframe = html.insertBefore( | |
| doc.createElement("iframe"), | |
| html.lastChild | |
| ), | |
| idoc = iframe.contentWindow.document || | |
| iframe.contentDocument || | |
| iframe.document, | |
| NullPrototype = Null.prototype = ( | |
| idoc.open(), | |
| idoc.write( | |
| '<script>parent.inherit=Object.prototype<' + | |
| '/script>' | |
| ), | |
| idoc.close(), | |
| inherit | |
| ), | |
| xtend = function xtend(object) { | |
| return xtend.prototype === object ? | |
| (xtend.prototype = xtend, this) : | |
| new xtend(xtend.prototype = object) | |
| ; | |
| }, | |
| iframe = html.removeChild(iframe), | |
| proto = [ | |
| "hasOwnProperty", | |
| "isPrototypeOf", | |
| "propertyIsEnumerable", | |
| "valueOf", | |
| "toString", | |
| "toLocaleString", | |
| "constructor" | |
| ], | |
| i = proto.length; i--; | |
| ) delete NullPrototype[proto[i]]; | |
| // you know ... IE, leaks, and shit ... | |
| create = iframe = html = doc = proto = NullPrototype = | |
| function(object) { | |
| return object == null ? new Null : xtend(object); | |
| } | |
| ; | |
| } else { | |
| create = function(object) { | |
| return {__proto__: object}; | |
| }; | |
| } | |
| } | |
| return function(object) { | |
| return create(object); | |
| }; | |
| }(Object.create)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment