diff --git a/browser/devtools/debugger/debugger-panes.js b/browser/devtools/debugger/debugger-panes.js index 25c8583749f5..6ac1f7bedc9f 100644 --- a/browser/devtools/debugger/debugger-panes.js +++ b/browser/devtools/debugger/debugger-panes.js @@ -2131,7 +2131,7 @@ LineResults.prototype.__iterator__ = function() { */ SourceResults.getItemForElement = LineResults.getItemForElement = function(aElement) { - return WidgetMethods.getItemForElement.call(this, aElement); + return WidgetMethods.getItemForElement.call(this, aElement, { noSiblings: true }); }; /** diff --git a/browser/devtools/shared/widgets/ViewHelpers.jsm b/browser/devtools/shared/widgets/ViewHelpers.jsm index 056094508e77..4f6732572a77 100644 --- a/browser/devtools/shared/widgets/ViewHelpers.jsm +++ b/browser/devtools/shared/widgets/ViewHelpers.jsm @@ -1237,15 +1237,23 @@ this.WidgetMethods = { * * @param nsIDOMNode aElement * The element used to identify the item. + * @param object aFlags [optional] + * Additional options for showing the source. Supported options: + * - noSiblings: if siblings shouldn't be taken into consideration + * when searching for the associated item. * @return Item * The matched item, or null if nothing is found. */ - getItemForElement: function(aElement) { + getItemForElement: function(aElement, aFlags = {}) { while (aElement) { - let item = - this._itemsByElement.get(aElement) || - this._itemsByElement.get(aElement.nextElementSibling) || - this._itemsByElement.get(aElement.previousElementSibling); + let item = this._itemsByElement.get(aElement); + + // Also search the siblings if allowed. + if (!aFlags.noSiblings) { + item = item || + this._itemsByElement.get(aElement.nextElementSibling) || + this._itemsByElement.get(aElement.previousElementSibling); + } if (item) { return item; }