Skip to content

Instantly share code, notes, and snippets.

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

This comment has been minimized.

Copy link

@ConAntonakos ConAntonakos commented Sep 11, 2015

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
You can’t perform that action at this time.