Skip to content

Instantly share code, notes, and snippets.

@chinchang
Last active September 15, 2016 09:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chinchang/a66fe3aedaf98b2433eb to your computer and use it in GitHub Desktop.
Save chinchang/a66fe3aedaf98b2433eb to your computer and use it in GitHub Desktop.
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