From b6b959c6481dd45e3ba9688283b29dc9d8154982 Mon Sep 17 00:00:00 2001 From: Mike Kucera Date: Thu, 26 Sep 2024 16:30:53 -0400 Subject: [PATCH] Attach the 'mousemove' handler to the window and the shadow DOM root. Refs #3273 --- .../renderer/base/load-listeners.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/extensions/renderer/base/load-listeners.js b/src/extensions/renderer/base/load-listeners.js index fddbb658a..e177f5a38 100644 --- a/src/extensions/renderer/base/load-listeners.js +++ b/src/extensions/renderer/base/load-listeners.js @@ -8,8 +8,20 @@ var BRp = {}; BRp.registerBinding = function( target, event, handler, useCapture ){ // eslint-disable-line no-unused-vars var args = Array.prototype.slice.apply( arguments, [1] ); // copy - var b = this.binder( target ); + if( Array.isArray(target) ){ + let res = []; + for( var i = 0; i < target.length; i++ ){ + let t = target[i]; + if( t !== undefined ){ + var b = this.binder( t ); + res.push( b.on.apply( b, args ) ); + } + } + return res; + } + + var b = this.binder( target ); return b.on.apply( b, args ); }; @@ -90,6 +102,14 @@ BRp.load = function(){ var containerWindow = r.cy.window(); var isSelected = ele => ele.selected(); + var getShadowRoot = function( element ){ + const rootNode = element.getRootNode(); + // Check if the root node is a shadow root + if ( rootNode && rootNode.nodeType === 11 && rootNode.host !== undefined ) { + return rootNode; + } + } + var triggerEvents = function( target, names, e, position ){ if( target == null ){ target = r.cy; @@ -560,7 +580,8 @@ BRp.load = function(){ }, false ); - r.registerBinding( containerWindow, 'mousemove', function mousemoveHandler( e ){ // eslint-disable-line no-undef + var shadowRoot = getShadowRoot( r.container ); + r.registerBinding( [ containerWindow, shadowRoot ], 'mousemove', function mousemoveHandler( e ){ // eslint-disable-line no-undef var capture = r.hoverData.capture; if( !capture && !eventInContainer(e) ){ return; }