mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-07 08:57:54 +08:00
fix addEventLister detection for IE9
IE9 added support for addEventListener and it looks like some new events (e.g. DOMContentLoaded) can't be registered via attachEvent, only addEventListener correctly registeres these. So to make sure we are using the latest and greatest we need to look for addEventListener instead of attachEvent in the jqLite feature detection code.
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
var jqCache = {},
|
||||
jqName = 'ng-' + new Date().getTime(),
|
||||
jqId = 1,
|
||||
addEventListenerFn = (window.document.attachEvent ?
|
||||
function(element, type, fn) {element.attachEvent('on' + type, fn);} :
|
||||
function(element, type, fn) {element.addEventListener(type, fn, false);}),
|
||||
removeEventListenerFn = (window.document.detachEvent ?
|
||||
function(element, type, fn) {element.detachEvent('on' + type, fn); } :
|
||||
function(element, type, fn) { element.removeEventListener(type, fn, false); });
|
||||
addEventListenerFn = (window.document.addEventListener ?
|
||||
function(element, type, fn) {element.addEventListener(type, fn, false);} :
|
||||
function(element, type, fn) {element.attachEvent('on' + type, fn);}),
|
||||
removeEventListenerFn = (window.document.removeEventListener ?
|
||||
function(element, type, fn) {element.removeEventListener(type, fn, false); } :
|
||||
function(element, type, fn) {element.detachEvent('on' + type, fn); });
|
||||
|
||||
function jqNextId() { return (jqId++); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user