Skip to content

Commit

Permalink
Keep global as a first-position-only keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Telroshan committed Nov 17, 2024
1 parent 0da28ca commit 9a9d7be
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(',')
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 9a9d7be

Please sign in to comment.