diff --git a/core/src/utils/gesture/pointer-events.ts b/core/src/utils/gesture/pointer-events.ts index f37a91896f7..a408cf4c37b 100644 --- a/core/src/utils/gesture/pointer-events.ts +++ b/core/src/utils/gesture/pointer-events.ts @@ -85,10 +85,10 @@ export class PointerEvents { return; } if (!this.rmMouseMove && this.pointerMove) { - this.rmMouseMove = addEventListener(this.el.ownerDocument, 'mousemove', this.pointerMove, this.options); + this.rmMouseMove = addEventListener(getDocument(this.el), 'mousemove', this.pointerMove, this.options); } if (!this.rmMouseUp) { - this.rmMouseUp = addEventListener(this.el.ownerDocument, 'mouseup', this.bindMouseUp, this.options); + this.rmMouseUp = addEventListener(getDocument(this.el), 'mouseup', this.bindMouseUp, this.options); } } @@ -130,6 +130,10 @@ export class PointerEvents { } } +function getDocument(node: Node) { + return node instanceof Document ? node : node.ownerDocument; +} + export const POINTER_EVENT_TYPE_MOUSE = 1; export const POINTER_EVENT_TYPE_TOUCH = 2;