diff options
Diffstat (limited to 'js/src/dom/selector-engine.js')
-rw-r--r-- | js/src/dom/selector-engine.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/js/src/dom/selector-engine.js b/js/src/dom/selector-engine.js index d66d8acfc8..c9d25f68cb 100644 --- a/js/src/dom/selector-engine.js +++ b/js/src/dom/selector-engine.js @@ -56,19 +56,17 @@ const SelectorEngine = { }, prev(element, selector) { - const siblings = [] + let previous = element.previousElementSibling - let previous = element.previousSibling - - while (previous && previous.nodeType === Node.ELEMENT_NODE && previous.nodeType !== NODE_TEXT) { + while (previous) { if (this.matches(previous, selector)) { - siblings.push(previous) + return [previous] } - previous = previous.previousSibling + previous = previous.previousElementSibling } - return siblings + return [] } } |