Skip to content

Instantly share code, notes, and snippets.

@chinchang
Last active September 15, 2016 09:22
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Make ReactJS work with unknown attributes
/**
*
* 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)
};
@ConAntonakos
Copy link

I received a ReferenceError: HTMLDOMPropertyConfig is not defined. Where do you place this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment