Last active
September 15, 2016 09:22
-
-
Save chinchang/a66fe3aedaf98b2433eb to your computer and use it in GitHub Desktop.
Make ReactJS work with unknown attributes
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
/** | |
* | |
* PATCH to make React work with custom attributes. | |
* | |
*/ | |
HTMLDOMPropertyConfig.isCustomAttribute = function(attr) { | |
// Strip off custom attributes React puts for its working. | |
if ({children: 1}[attr]) { return false; } | |
// Take any attribute (with correct syntax) as custom attribute. | |
return /^(data|aria)*-*[a-z_][a-z\d_.\-]*$/.test(attr) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I received a ReferenceError:
HTMLDOMPropertyConfig is not defined
. Where do you place this?