made with esnextbin
Last active
March 9, 2016 10:00
-
-
Save nfcampos/855bfa9e62fe604b5fa8 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains 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
const realCreateElement = React.createElement | |
const Components = new Set() | |
const patchPrototype = (Component) => { | |
Components.add(Component) | |
for (const method of Object.keys(Component.prototype)) { | |
if (typeof Component.prototype[method] == 'function') { | |
const bind = (ctx, ...boundArgs) => { | |
const fn = (...args) => { | |
return Component.prototype[method].call(ctx, ...boundArgs, ...args) | |
} | |
fn.bind = bind | |
return fn | |
} | |
Component.prototype[method].bind = bind | |
} | |
} | |
} | |
React.createElement = function createElement(type, ...args) { | |
if (React.Component.prototype.isPrototypeOf(type) && !Components.has(type)) { | |
patchPrototype(type) | |
} | |
return realCreateElement(type, ...args) | |
} | |
// actually this still doesn't work for eg. flux store listeners (I think) | |
// but I think I know how to make it work | |
// (ie. how to make sure Component.prototype[method] always points to the same reference) |
This file contains 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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0" | |
} |
This file contains 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
/* | |
unknown: Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got null | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment