* Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result
(fn)
| 328 | */ |
| 329 | |
| 330 | function assert(fn) { |
| 331 | var div = document.createElement("div"); |
| 332 | |
| 333 | try { |
| 334 | return !!fn(div); |
| 335 | } catch (e) { |
| 336 | return false; |
| 337 | } finally { |
| 338 | // Remove from its parent by default |
| 339 | if (div.parentNode) { |
| 340 | div.parentNode.removeChild(div); |
| 341 | } |
| 342 | // release memory in IE |
| 343 | div = null; |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Adds the same handler for all of the specified attrs |