Created
December 9, 2012 22:14
-
-
Save constantology/4247253 to your computer and use it in GitHub Desktop.
easy way to get a list of every expando property on all the supplied element in a list
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
var val = [document, new Date(), true, 1, 'foo']; | |
'a abbr acronym address area article aside audio b bdi bdo big blockquote body br button canvas caption ' | |
+ 'cite code col colgroup command datalist dd del details dfn div dl dt em embed fieldset figcaption ' | |
+ 'figure footer form frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins ' | |
+ 'kbd keygen label legend li link map mark meta meter nav noscript object ol optgroup option output p ' | |
+ 'param pre progress q rp rt ruby samp script section select small source span split strong style sub ' | |
+ 'summary sup table tbody td textarea tfoot th thead time title tr track tt ul var video wbr'.split( ' ' ).map( function( tag ) { | |
var el = document.createElement( tag ); | |
return Object.getOwnPropertyNames( el ).filter( function( attr ) { | |
var value = val.concat( [attr] ), i = value.length; | |
while ( --i >= 0 ) { | |
try { | |
el[attr] = value[i]; | |
if ( el[attr] === value[i] ) | |
return true; | |
} | |
catch ( e ) { | |
console.log( 'FAILED: ', el.tagName, ', property: ', attr, ', value: ', value[i] ); | |
} | |
} | |
return false; | |
} ).sort().join( ' ' ); | |
} ).join( ' ' ).split( ' ' ).sort().reduce( function( res, attr ) { | |
res.indexOf( attr ) > -1 || res.push( attr ); | |
return res; | |
}, [] ).join( ' ' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment