* Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result
( fn )
| 877 | * @param {Function} fn Passed the created div and expects a boolean result |
| 878 | */ |
| 879 | function assert( fn ) { |
| 880 | var div = document.createElement("div"); |
| 881 | |
| 882 | try { |
| 883 | return !!fn( div ); |
| 884 | } catch (e) { |
| 885 | return false; |
| 886 | } finally { |
| 887 | // Remove from its parent by default |
| 888 | if ( div.parentNode ) { |
| 889 | div.parentNode.removeChild( div ); |
| 890 | } |
| 891 | // release memory in IE |
| 892 | div = null; |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | /** |
| 897 | * Adds the same handler for all of the specified attrs |