From b3a2c9c5d3b24cd8bfb240b3859f7501b7117369 Mon Sep 17 00:00:00 2001 From: Deathamns Date: Tue, 10 Feb 2015 18:22:17 +0100 Subject: [PATCH] Get URLs with properties instead of getAttribute --- src/js/element-picker.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/js/element-picker.js b/src/js/element-picker.js index f1e772ffc..c94857259 100644 --- a/src/js/element-picker.js +++ b/src/js/element-picker.js @@ -137,7 +137,6 @@ var svgOcean = null; var svgIslands = null; var dialog = null; var taCandidate = null; -var urlNormalizer = null; var netFilterCandidates = []; var cosmeticFilterCandidates = []; @@ -246,8 +245,8 @@ var netFilterFromElement = function(elem, out) { if ( netFilterSources.hasOwnProperty(tagName) === false ) { return; } - var src = elem.getAttribute(netFilterSources[tagName]); - if ( typeof src !== 'string' || src.length === 0 ) { + var src = elem[netFilterSources[tagName]]; + if ( src.length === 0 ) { return; } // Remove fragment @@ -255,10 +254,6 @@ var netFilterFromElement = function(elem, out) { if ( pos !== -1 ) { src = src.slice(0, pos); } - // Feed the attribute to a link element, then retrieve back: this - // should normalize it. - urlNormalizer.href = src; - src = urlNormalizer.href; // Anchor absolute filter to hostname src = src.replace(/^https?:\/\//, '||'); out.push(src); @@ -417,11 +412,7 @@ var elementsFromFilter = function(filter) { while ( i-- ) { elem = elems[i]; src = elem[netFilterSources[elem.tagName.toLowerCase()]]; - if ( typeof src !== 'string' ) { - continue; - } - - if ( src.indexOf(filter) !== -1 ) { + if ( src && src.indexOf(filter) !== -1 ) { out.push(elem); } } @@ -682,8 +673,7 @@ var stopPicker = function() { pickerRoot = dialog = svgOcean = svgIslands = - taCandidate = - urlNormalizer = null; + taCandidate = null; localMessager.close(); window.focus(); @@ -722,8 +712,6 @@ var startPicker = function(details) { svgIslands = svgRoot.lastChild; svgListening(true); - urlNormalizer = document.createElement('a'); - window.addEventListener('scroll', onScrolled, true); pickerRoot.contentWindow.addEventListener('keydown', onKeyPressed, true); pickerRoot.contentWindow.focus();