From a6b01cb0e59ec0b705362aa75686de383731168b Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 4 Oct 2017 11:14:24 -0400 Subject: [PATCH] fix #3090 --- src/js/scriptlets/element-picker.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/js/scriptlets/element-picker.js b/src/js/scriptlets/element-picker.js index fb264987b..82d5ebc1b 100644 --- a/src/js/scriptlets/element-picker.js +++ b/src/js/scriptlets/element-picker.js @@ -1416,7 +1416,7 @@ var stopPicker = function() { svgRoot.removeEventListener('touchend', onSvgTouchStartStop); pickerStyle.parentNode.removeChild(pickerStyle); pickerRoot.parentNode.removeChild(pickerRoot); - pickerRoot.onload = null; + pickerRoot.removeEventListener('load', stopPicker); pickerRoot = pickerBody = dialog = @@ -1429,7 +1429,7 @@ var stopPicker = function() { /******************************************************************************/ var startPicker = function(details) { - pickerRoot.onload = stopPicker; + pickerRoot.addEventListener('load', stopPicker); var frameDoc = pickerRoot.contentDocument; var parsedDom = (new DOMParser()).parseFromString( @@ -1534,6 +1534,18 @@ var startPicker = function(details) { /******************************************************************************/ +var bootstrapPicker = function() { + pickerRoot.removeEventListener('load', bootstrapPicker); + vAPI.shutdown.add(stopPicker); + vAPI.messaging.send( + 'elementPicker', + { what: 'elementPickerArguments' }, + startPicker + ); +}; + +/******************************************************************************/ + pickerRoot = document.createElement('iframe'); pickerRoot.id = vAPI.sessionId; pickerRoot.style.cssText = [ @@ -1581,19 +1593,9 @@ if ( vAPI.userCSS ) { vAPI.userCSS.add(pickerStyle.textContent); } -pickerRoot.onload = function() { - vAPI.shutdown.add(stopPicker); - vAPI.messaging.send( - 'elementPicker', - { what: 'elementPickerArguments' }, - startPicker - ); -}; - +pickerRoot.addEventListener('load', bootstrapPicker); document.documentElement.appendChild(pickerRoot); -// https://www.youtube.com/watch?v=sociXdKnyr8 - /******************************************************************************/ })();