From 980125b8afcf8d5d32eeeb39a2668fb32e454117 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 3 Aug 2015 09:25:18 -0400 Subject: [PATCH] minor code review --- platform/chromium/vapi-background.js | 5 +---- src/js/contentscript-end.js | 5 +++-- src/js/contentscript-start.js | 5 +++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 8bedd1519..62371248d 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -375,11 +375,8 @@ vAPI.tabs.open = function(details) { // "Note that fragment identifiers are not matched." // It's a lie, fragment identifiers ARE matched. So we need to remove the // fragment. - var targetURLWithoutHash = targetURL; var pos = targetURL.indexOf('#'); - if ( pos !== -1 ) { - targetURLWithoutHash = targetURL.slice(0, pos); - } + var targetURLWithoutHash = pos === -1 ? targetURL : targetURL.slice(0, pos); chrome.tabs.query({ url: targetURLWithoutHash }, function(tabs) { var tab = tabs[0]; diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 72de45c68..180fa8094 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -470,8 +470,9 @@ var uBlockCollapser = (function() { if ( shadow !== null && shadow.className === sessionId ) { continue; } - // https://github.com/w3c/webcomponents/issues/102 - // not all nodes can be shadowed + // https://github.com/gorhill/uBlock/pull/555 + // Not all nodes can be shadowed: + // https://github.com/w3c/webcomponents/issues/102 try { shadow = elem.createShadowRoot(); shadow.className = sessionId; diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js index 7b4ca4c18..f45d904e9 100644 --- a/src/js/contentscript-start.js +++ b/src/js/contentscript-start.js @@ -181,8 +181,9 @@ var hideElements = function(selectors) { if ( shadow !== null && shadow.className === sessionId ) { continue; } - // https://github.com/w3c/webcomponents/issues/102 - // not all nodes can be shadowed + // https://github.com/gorhill/uBlock/pull/555 + // Not all nodes can be shadowed: + // https://github.com/w3c/webcomponents/issues/102 try { shadow = elem.createShadowRoot(); shadow.className = sessionId;