From 1a833760344575f9da132486eff758001ff71d5e Mon Sep 17 00:00:00 2001 From: wanabe Date: Thu, 12 Sep 2013 12:36:00 +0900 Subject: [PATCH] Improved compatibility with "How Many Times Can I Back?" (#397) "getCommonAncestor" method is not available without jQuery --- modules/browser.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index 395d4895..e5f779d0 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -1079,10 +1079,16 @@ TreeStyleTabBrowser.prototype = { namedNodes.closeAnchor = namedNodes.label; if (namedNodes.closeAnchor.parentNode != namedNodes.close.parentNode) { - let containerFinder = d.createRange(); - containerFinder.selectNode(namedNodes.closeAnchor); - containerFinder.setEndAfter(namedNodes.close); - let container = containerFinder.getCommonAncestor(); + let containerFinder = namedNodes.closeAnchor; + let containers = []; + while (containerFinder != aTab) { + containerFinder = containerFinder.parentNode; + containers.push(containerFinder); + } + let container = namedNodes.close; + while (containers.indexOf(container) < 0) { + container = container.parentNode; + } while (namedNodes.closeAnchor.parentNode != container) { namedNodes.closeAnchor = namedNodes.closeAnchor.parentNode;