* @param {HTMLElement} elem * @param {string} type * @param {Function} fn
( elem, type, fn )
| 1099 | * @param {Function} fn |
| 1100 | */ |
| 1101 | function addEvent( elem, type, fn ) { |
| 1102 | if ( elem.addEventListener ) { |
| 1103 | |
| 1104 | // Standards-based browsers |
| 1105 | elem.addEventListener( type, fn, false ); |
| 1106 | } else if ( elem.attachEvent ) { |
| 1107 | |
| 1108 | // support: IE <9 |
| 1109 | elem.attachEvent( "on" + type, fn ); |
| 1110 | } else { |
| 1111 | |
| 1112 | // Caller must ensure support for event listeners is present |
| 1113 | throw new Error( "addEvent() was called in a context without event listener support" ); |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | /** |
| 1118 | * @param {Array|NodeList} elems |