* Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result
( fn )
| 339 | * @param {Function} fn Passed the created div and expects a boolean result |
| 340 | */ |
| 341 | function assert( fn ) { |
| 342 | var div = document.createElement("div"); |
| 343 | |
| 344 | try { |
| 345 | return !!fn( div ); |
| 346 | } catch (e) { |
| 347 | return false; |
| 348 | } finally { |
| 349 | // Remove from its parent by default |
| 350 | if ( div.parentNode ) { |
| 351 | div.parentNode.removeChild( div ); |
| 352 | } |
| 353 | // release memory in IE |
| 354 | div = null; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * Adds the same handler for all of the specified attrs |