* Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result
( fn )
| 889 | * @param {Function} fn Passed the created div and expects a boolean result |
| 890 | */ |
| 891 | function assert( fn ) { |
| 892 | var div = document.createElement("div"); |
| 893 | |
| 894 | try { |
| 895 | return !!fn( div ); |
| 896 | } catch (e) { |
| 897 | return false; |
| 898 | } finally { |
| 899 | // Remove from its parent by default |
| 900 | if ( div.parentNode ) { |
| 901 | div.parentNode.removeChild( div ); |
| 902 | } |
| 903 | // release memory in IE |
| 904 | div = null; |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | /** |
| 909 | * Adds the same handler for all of the specified attrs |