From 998850b21e05578e7281df8105b898c260b2f30f Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Tue, 21 Jun 2016 17:07:45 +0900 Subject: [PATCH] Detect reference node with XPath --- modules/browser.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index 7b0ddee7..6c4b0882 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -981,7 +981,12 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { let insertAfter = item.getAttribute('multipletab-insertafter'); if (insertAfter) { try { - (new Function('return refNode = ('+insertAfter+').nextSibling'))(); + refNode = utils.evaluateXPath( + insertAfter.replace(/^\s*xpath:\s*/i, ''), + tabContextMenu, + Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE + ).singleNodeValue; + if (refNode) refNode = refNode.nextSibling; } catch(e) { } @@ -989,7 +994,11 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { let insertBefore = item.getAttribute('multipletab-insertbefore'); if (refNode === void(0) && insertBefore) { try { - (new Function('return refNode = '+insertBefore))(); + refNode = utils.evaluateXPath( + insertBefore.replace(/^\s*xpath:\s*/i, ''), + tabContextMenu, + Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE + ).singleNodeValue; } catch(e) { }