* Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result
( fn )
| 913 | * @param {Function} fn Passed the created div and expects a boolean result |
| 914 | */ |
| 915 | function assert( fn ) { |
| 916 | var div = document.createElement("div"); |
| 917 | |
| 918 | try { |
| 919 | return !!fn( div ); |
| 920 | } catch (e) { |
| 921 | return false; |
| 922 | } finally { |
| 923 | // Remove from its parent by default |
| 924 | if ( div.parentNode ) { |
| 925 | div.parentNode.removeChild( div ); |
| 926 | } |
| 927 | // release memory in IE |
| 928 | div = null; |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * Adds the same handler for all of the specified attrs |