Created
September 30, 2014 22:17
-
-
Save martynsmith/f03ddb808612a2b18c15 to your computer and use it in GitHub Desktop.
Overriding React DOM classes
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
(function() { | |
return; | |
var ReactDescriptor = require('react/lib/ReactDescriptor'); | |
var old = ReactDescriptor.createFactory; | |
ReactDescriptor.createFactory = function() { | |
var factory = old.apply(this, arguments); | |
//console.log(factory); | |
//console.log(console.dir(factory)); | |
//return factory; | |
var newFactory = function(props) { | |
if (props && typeof(props) === 'object') { | |
if ('onClick' in props) { | |
console.error("Using onClick and you shouldn't"); | |
} | |
// TODO - mangle some stuff | |
} | |
return factory.apply(this, arguments); | |
}; | |
newFactory.prototype = factory.prototype; | |
for (var k in factory) { | |
if (factory.hasOwnProperty(k)) { | |
newFactory[k] = factory[k]; | |
} | |
} | |
return newFactory; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment