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/capture.js b/src/capture.js index 464e7724..e07b45e5 100644 --- a/src/capture.js +++ b/src/capture.js @@ -32,7 +32,7 @@ dispatcher.releaseCapture(pointerId, this); }; } - if (!Element.prototype.setPointerCapture) { + if (window.Element && !Element.prototype.setPointerCapture) { Object.defineProperties(Element.prototype, { 'setPointerCapture': { value: s 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); diff --git a/src/mouse.js b/src/mouse.js index 9601eb23..e7138b7e 100644 --- a/src/mouse.js +++ b/src/mouse.js @@ -94,7 +94,7 @@ this.cleanupMouse(); }, cleanupMouse: function() { - pointermap.delete(this.POINTER_ID); + pointermap['delete'](this.POINTER_ID); } }; diff --git a/src/ms.js b/src/ms.js index 7d0c3564..f35f888f 100644 --- a/src/ms.js +++ b/src/ms.js @@ -41,7 +41,7 @@ return e; }, cleanup: function(id) { - pointermap.delete(id); + pointermap['delete'](id); }, MSPointerDown: function(inEvent) { pointermap.set(inEvent.pointerId, inEvent); diff --git a/src/touch.js b/src/touch.js index 0a5c45de..24768ac3 100644 --- a/src/touch.js +++ b/src/touch.js @@ -54,11 +54,11 @@ } }, elementRemoved: function(el) { - this.scrollType.delete(el); + this.scrollType['delete'](el); dispatcher.unlisten(el, this.events); // remove touch-action from shadow allShadows(el).forEach(function(s) { - this.scrollType.delete(s); + this.scrollType['delete'](s); dispatcher.unlisten(s, this.events); }, this); }, @@ -291,7 +291,7 @@ this.cleanUpPointer(inPointer); }, cleanUpPointer: function(inPointer) { - pointermap.delete(inPointer.pointerId); + pointermap['delete'](inPointer.pointerId); this.removePrimaryPointer(inPointer); }, // prevent synth mouse events from creating pointer events