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