From 9a9d7bed093be63cfd6d88db87ca2cfb740ff257 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sun, 17 Nov 2024 22:29:41 +0100 Subject: [PATCH] Keep global as a first-position-only keyword --- src/htmx.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/htmx.js b/src/htmx.js index 243a6a8fe..ef425dbb8 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -1128,6 +1128,10 @@ var htmx = (function() { * @returns {(Node|Window)[]} */ function querySelectorAllExt(elt, selector, global) { + if (selector.indexOf('global ') === 0) { + return querySelectorAllExt(elt, selector.slice(7), true) + } + elt = resolveTarget(elt) const parts = selector.split(',') @@ -1158,12 +1162,6 @@ var htmx = (function() { item = getRootNode(elt, !!global) } else if (selector === 'host') { item = (/** @type ShadowRoot */(elt.getRootNode())).host - } else if (selector.indexOf('global ') === 0) { - // Previous implementation of `global` only supported it at the first position and applied it to the entire selector string. - // For backward compatibility and to maintain logical consistency, we make it apply to everything that follows. - parts.unshift(selector.slice(7)) - result.push(...querySelectorAllExt(elt, parts.join(','), true)) - break } else { unprocessedParts.push(selector) }