* Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result
( fn )
| 937 | * @param {Function} fn Passed the created div and expects a boolean result |
| 938 | */ |
| 939 | function assert( fn ) { |
| 940 | var div = document.createElement("div"); |
| 941 | |
| 942 | try { |
| 943 | return !!fn( div ); |
| 944 | } catch (e) { |
| 945 | return false; |
| 946 | } finally { |
| 947 | // Remove from its parent by default |
| 948 | if ( div.parentNode ) { |
| 949 | div.parentNode.removeChild( div ); |
| 950 | } |
| 951 | // release memory in IE |
| 952 | div = null; |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | /** |
| 957 | * Adds the same handler for all of the specified attrs |