Skip to content

Instantly share code, notes, and snippets.

@matijs
Last active June 29, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matijs/25311136539a74f4437f8db3cb4a7437 to your computer and use it in GitHub Desktop.
Save matijs/25311136539a74f4437f8db3cb4a7437 to your computer and use it in GitHub Desktop.
function isInteractiveElement( element ) {
if ( [ 'A', 'BUTTON', 'DETAILS', 'EMBED', 'IFRAME', 'KEYGEN', 'LABEL', 'SELECT', 'TEXTAREA' ].indexOf( element.nodeName ) !== -1 ) {
return true;
}
if ( element.nodeName === 'INPUT' && element.type !== 'hidden' ) {
return true;
}
if ( ['AUDIO', 'VIDEO'].indexOf( element.nodeName ) > -1 && element.hasAttribute('controls') ) {
return true;
}
if ( ['IMG', 'OBJECT'].indexOf( element.nodeName ) > -1 && element.hasAttribute('usemap') ) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment