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:
Raymond Hill 2023-12-16 11:23:58 -05:00
parent c2b5fb1fda
commit ebd9d93666
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 10 additions and 6 deletions

View File

@ -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);