mirror of https://github.com/gorhill/uBlock.git
Prevent element picker from throwing when targeting `html`/`body`
Occurred when element picker was launched from context menu as a result of clicking on `html` or `body` elements.
This commit is contained in:
parent
c2b5fb1fda
commit
ebd9d93666
|
@ -1140,13 +1140,16 @@ const quitPicker = function() {
|
||||||
self.removeEventListener('resize', onViewportChanged, { passive: true });
|
self.removeEventListener('resize', onViewportChanged, { passive: true });
|
||||||
self.removeEventListener('keydown', onKeyPressed, true);
|
self.removeEventListener('keydown', onKeyPressed, true);
|
||||||
vAPI.shutdown.remove(quitPicker);
|
vAPI.shutdown.remove(quitPicker);
|
||||||
|
if ( pickerFramePort !== null ) {
|
||||||
pickerFramePort.close();
|
pickerFramePort.close();
|
||||||
pickerFramePort = undefined;
|
pickerFramePort = null;
|
||||||
vAPI.userStylesheet.remove(pickerCSS);
|
}
|
||||||
vAPI.userStylesheet.apply();
|
if ( pickerRoot !== null ) {
|
||||||
if ( pickerRoot === null ) { return; }
|
|
||||||
pickerRoot.remove();
|
pickerRoot.remove();
|
||||||
pickerRoot = null;
|
pickerRoot = null;
|
||||||
|
}
|
||||||
|
vAPI.userStylesheet.remove(pickerCSS);
|
||||||
|
vAPI.userStylesheet.apply();
|
||||||
self.focus();
|
self.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1156,6 +1159,7 @@ const onDialogMessage = function(msg) {
|
||||||
switch ( msg.what ) {
|
switch ( msg.what ) {
|
||||||
case 'start':
|
case 'start':
|
||||||
startPicker();
|
startPicker();
|
||||||
|
if ( pickerFramePort === null ) { break; }
|
||||||
if ( targetElements.length === 0 ) {
|
if ( targetElements.length === 0 ) {
|
||||||
highlightElements([], true);
|
highlightElements([], true);
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1305,7 @@ document.documentElement.append(pickerRoot);
|
||||||
|
|
||||||
vAPI.shutdown.add(quitPicker);
|
vAPI.shutdown.add(quitPicker);
|
||||||
|
|
||||||
let pickerFramePort;
|
let pickerFramePort = null;
|
||||||
|
|
||||||
{
|
{
|
||||||
const url = new URL(pickerBootArgs.pickerURL);
|
const url = new URL(pickerBootArgs.pickerURL);
|
||||||
|
|
Loading…
Reference in New Issue