* This method attempts to bind a function to global. * * @param {Function} [func] The function to be bound * @return {Function} Returns the bound function or func
(func)
| 506 | * @return {Function} Returns the bound function or func |
| 507 | */ |
| 508 | function maybeBindToGlobal(func) { |
| 509 | if (func && global && |
| 510 | global['EventTarget'] && |
| 511 | typeof global['EventTarget'].prototype.addEventListener === 'function' && |
| 512 | typeof func.bind === 'function') { |
| 513 | return func.bind(global); |
| 514 | } |
| 515 | return func; |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * Initializing storage for the custom state's object |