Skip to content

Commit

Permalink
Fix oobElement root check
Browse files Browse the repository at this point in the history
  • Loading branch information
infogulch committed Feb 27, 2024
1 parent 92b2bd7 commit 37965cc
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ var htmx = (function() {
*/
function findAndSwapOobElements(fragment, settleInfo) {
forEach(findAll(fragment, '[hx-swap-oob], [data-hx-swap-oob]'), function(oobElement) {
if (htmx.config.allowNestedOobSwaps || oobElement.parentElement.nodeName === 'BODY') {
if (htmx.config.allowNestedOobSwaps || oobElement.parentElement === null) {
var oobValue = getAttributeValue(oobElement, 'hx-swap-oob')
if (oobValue != null) {
oobSwap(oobValue, oobElement, settleInfo)
Expand Down Expand Up @@ -2037,7 +2037,7 @@ var htmx = (function() {
const conditionFunction = maybeEval(elt, function() {
return Function(conditionalSource)()
},
function() { return true })
function() { return true })
conditionFunction.source = conditionalSource
return conditionFunction
} catch (e) {
Expand Down Expand Up @@ -3028,7 +3028,7 @@ var htmx = (function() {
try {
disableHistoryCache = getDocument().querySelector('[hx-history="false" i],[data-hx-history="false" i]')
} catch (e) {
// IE11: insensitive modifier not supported so fallback to case sensitive selector
// IE11: insensitive modifier not supported so fallback to case sensitive selector
disableHistoryCache = getDocument().querySelector('[hx-history="false"],[data-hx-history="false"]')
}
if (!disableHistoryCache) {
Expand All @@ -3043,7 +3043,7 @@ var htmx = (function() {
* @param {string} path
*/
function pushUrlIntoHistory(path) {
// remove the cache buster parameter, if any
// remove the cache buster parameter, if any
if (htmx.config.getCacheBusterParam) {
path = path.replace(/org\.htmx\.cache-buster=[^&]*&?/, '')
if (endsWith(path, '&') || endsWith(path, '?')) {
Expand Down Expand Up @@ -3373,7 +3373,7 @@ var htmx = (function() {

// if a button or submit was clicked last, include its value
if (internalData.lastButtonClicked || elt.tagName === 'BUTTON' ||
(elt.tagName === 'INPUT' && getRawAttribute(elt, 'type') === 'submit')) {
(elt.tagName === 'INPUT' && getRawAttribute(elt, 'type') === 'submit')) {
const button = internalData.lastButtonClicked || (/** @type HTMLInputElement|HTMLButtonElement */(elt))
const name = getRawAttribute(button, 'name')
addValueToFormData(name, button.value, priorityFormData)
Expand Down Expand Up @@ -3565,7 +3565,7 @@ var htmx = (function() {
*/
function usesFormData(elt) {
return getClosestAttributeValue(elt, 'hx-encoding') === 'multipart/form-data' ||
(matches(elt, 'form') && getRawAttribute(elt, 'enctype') === 'multipart/form-data')
(matches(elt, 'form') && getRawAttribute(elt, 'enctype') === 'multipart/form-data')
}

/**
Expand Down Expand Up @@ -3743,7 +3743,7 @@ var htmx = (function() {
try {
xhr.setRequestHeader(header, headerValue)
} catch (e) {
// On an exception, try to set the header URI encoded instead
// On an exception, try to set the header URI encoded instead
xhr.setRequestHeader(header, encodeURIComponent(headerValue))
xhr.setRequestHeader(header + '-URI-AutoEncoded', 'true')
}
Expand All @@ -3755,7 +3755,7 @@ var htmx = (function() {
* @return {string}
*/
function getPathFromResponse(xhr) {
// NB: IE11 does not support this stuff
// NB: IE11 does not support this stuff
if (xhr.responseURL && typeof (URL) !== 'undefined') {
try {
const url = new URL(xhr.responseURL)
Expand Down Expand Up @@ -3839,7 +3839,7 @@ var htmx = (function() {
const origin = document.location.origin
sameHost = origin === url.origin
} else {
// IE11 doesn't support URL
// IE11 doesn't support URL
url = path
sameHost = startsWith(path, document.location.origin)
}
Expand Down Expand Up @@ -4003,7 +4003,7 @@ var htmx = (function() {
const select = etc.select || null

if (!bodyContains(elt)) {
// do not issue requests for elements removed from the DOM
// do not issue requests for elements removed from the DOM
maybeCall(resolve)
return promise
}
Expand All @@ -4025,7 +4025,7 @@ var htmx = (function() {

const buttonVerb = getRawAttribute(submitter, 'formmethod')
if (buttonVerb != null) {
// ignore buttons with formmethod="dialog"
// ignore buttons with formmethod="dialog"
if (buttonVerb.toLowerCase() !== 'dialog') {
verb = (/** @type HttpVerb */(buttonVerb))
}
Expand Down Expand Up @@ -4122,7 +4122,7 @@ var htmx = (function() {
eltData.xhr = null
eltData.abortable = false
if (eltData.queuedRequests != null &&
eltData.queuedRequests.length > 0) {
eltData.queuedRequests.length > 0) {
const queuedRequest = eltData.queuedRequests.shift()
queuedRequest()
}
Expand All @@ -4132,7 +4132,7 @@ var htmx = (function() {
var promptResponse = prompt(promptQuestion)
// prompt returns null if cancelled and empty string if accepted with no entry
if (promptResponse === null ||
!triggerEvent(elt, 'htmx:prompt', { prompt: promptResponse, target })) {
!triggerEvent(elt, 'htmx:prompt', { prompt: promptResponse, target })) {
maybeCall(resolve)
endRequestLock()
return promise
Expand Down Expand Up @@ -4260,7 +4260,7 @@ var htmx = (function() {

// request headers
if (requestAttrValues.noHeaders) {
// ignore all headers
// ignore all headers
} else {
for (const header in headers) {
if (headers.hasOwnProperty(header)) {
Expand Down Expand Up @@ -4429,7 +4429,7 @@ var htmx = (function() {
}

if (path) {
// false indicates no push, return empty object
// false indicates no push, return empty object
if (path === 'false') {
return {}
}
Expand Down Expand Up @@ -4693,10 +4693,10 @@ var htmx = (function() {
}

if (shouldTransition &&
triggerEvent(elt, 'htmx:beforeTransition', responseInfo) &&
typeof Promise !== 'undefined' &&
// @ts-ignore experimental feature atm
document.startViewTransition) {
triggerEvent(elt, 'htmx:beforeTransition', responseInfo) &&
typeof Promise !== 'undefined' &&
// @ts-ignore experimental feature atm
document.startViewTransition) {
const settlePromise = new Promise(function(_resolve, _reject) {
settleResolve = _resolve
settleReject = _reject
Expand Down

0 comments on commit 37965cc

Please sign in to comment.