diff --git a/src/boot.js b/src/boot.js index c6d552b4..f0226591 100644 --- a/src/boot.js +++ b/src/boot.js @@ -6,6 +6,7 @@ (function(scope) { scope = scope || {}; + scope.external = scope.external || {}; var target = { shadow: function(inEl) { if (inEl) { diff --git a/src/dispatcher.js b/src/dispatcher.js index 058fcdc4..7d11d239 100644 --- a/src/dispatcher.js +++ b/src/dispatcher.js @@ -131,6 +131,9 @@ es.unregister.call(es, element); } }, + contains: scope.external.contains || function(container, contained) { + return container.contains(contained); + }, // EVENTS down: function(inEvent) { this.fireEvent('pointerdown', inEvent); @@ -161,13 +164,13 @@ this.fireEvent('pointercancel', inEvent); }, leaveOut: function(event) { - if (!event.target.contains(event.relatedTarget)) { + if (!this.contains(event.target, event.relatedTarget)) { this.leave(event); } this.out(event); }, enterOver: function(event) { - if (!event.target.contains(event.relatedTarget)) { + if (!this.contains(event.target, event.relatedTarget)) { this.enter(event); } this.over(event); @@ -199,10 +202,10 @@ this.removeEvent(target, e); }, this); }, - addEvent: function(target, eventName) { + addEvent: scope.external.addEvent || function(target, eventName) { target.addEventListener(eventName, this.boundHandler); }, - removeEvent: function(target, eventName) { + removeEvent: scope.external.removeEvent || function(target, eventName) { target.removeEventListener(eventName, this.boundHandler); }, // EVENT CREATION AND TRACKING @@ -282,7 +285,7 @@ * @param {Event} inEvent The event to be dispatched. * @return {Boolean} True if an event handler returns true, false otherwise. */ - dispatchEvent: function(inEvent) { + dispatchEvent: scope.external.dispatchEvent || function(inEvent) { var t = this.getTarget(inEvent); if (t) { return t.dispatchEvent(inEvent);