mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-01-24 20:56:15 +00:00
make linter happy
This commit is contained in:
28
src/htmx.js
28
src/htmx.js
@@ -25,7 +25,7 @@ var htmx = (function() {
|
||||
removeClass: removeClassFromElement,
|
||||
toggleClass: toggleClassOnElement,
|
||||
takeClass: takeClassForElement,
|
||||
swap: swap,
|
||||
swap,
|
||||
/* Extension entrypoints */
|
||||
defineExtension,
|
||||
removeExtension,
|
||||
@@ -405,8 +405,8 @@ var htmx = (function() {
|
||||
*/
|
||||
/**
|
||||
* @template T
|
||||
* @param {{[index: number]: T, length: number}} arr
|
||||
* @param {forEachCallback<T>} func
|
||||
* @param {{[index: number]: T, length: number}} arr
|
||||
* @param {forEachCallback<T>} func
|
||||
*/
|
||||
function forEach(arr, func) {
|
||||
if (arr) {
|
||||
@@ -1145,7 +1145,7 @@ var htmx = (function() {
|
||||
swapOptions = {}
|
||||
}
|
||||
|
||||
target = resolveTarget(target);
|
||||
target = resolveTarget(target)
|
||||
|
||||
// preserve focus and selection
|
||||
const activeElt = document.activeElement
|
||||
@@ -1161,9 +1161,9 @@ var htmx = (function() {
|
||||
} catch (e) {
|
||||
// safari issue - see https://github.com/microsoft/playwright/issues/5894
|
||||
}
|
||||
let settleInfo = makeSettleInfo(target);
|
||||
const settleInfo = makeSettleInfo(target)
|
||||
|
||||
let fragment = makeFragment(content);
|
||||
let fragment = makeFragment(content)
|
||||
|
||||
settleInfo.title = fragment.title
|
||||
settleInfo.head = fragment.head
|
||||
@@ -1202,8 +1202,8 @@ var htmx = (function() {
|
||||
})
|
||||
fragment = newFragment
|
||||
}
|
||||
handlePreservedElements(fragment);
|
||||
swapWithStyle(swapSpec.swapStyle, swapOptions.contextElement, target, fragment, settleInfo);
|
||||
handlePreservedElements(fragment)
|
||||
swapWithStyle(swapSpec.swapStyle, swapOptions.contextElement, target, fragment, settleInfo)
|
||||
|
||||
// apply saved focus and selection information to swapped content
|
||||
if (selectionInfo.elt &&
|
||||
@@ -1233,15 +1233,15 @@ var htmx = (function() {
|
||||
triggerEvent(elt, 'htmx:afterSwap', swapOptions.eventInfo)
|
||||
})
|
||||
if (swapOptions.afterSwapCallback) {
|
||||
swapOptions.afterSwapCallback();
|
||||
swapOptions.afterSwapCallback()
|
||||
}
|
||||
|
||||
// merge in new head after swap but before settle
|
||||
if (!swapSpec.ignoreTitle) {
|
||||
handleTitle(settleInfo.title);
|
||||
handleTitle(settleInfo.title)
|
||||
}
|
||||
if (triggerEvent(document.body, "htmx:beforeHeadMerge", {head: settleInfo.head})) {
|
||||
handleHeadTag(settleInfo.head, swapSpec.head);
|
||||
if (triggerEvent(document.body, 'htmx:beforeHeadMerge', { head: settleInfo.head })) {
|
||||
handleHeadTag(settleInfo.head, swapSpec.head)
|
||||
}
|
||||
|
||||
// settle
|
||||
@@ -1257,7 +1257,7 @@ var htmx = (function() {
|
||||
})
|
||||
|
||||
if (swapOptions.anchor) {
|
||||
const anchorTarget = resolveTarget(swapOptions.anchor);
|
||||
const anchorTarget = resolveTarget(swapOptions.anchor)
|
||||
if (anchorTarget) {
|
||||
anchorTarget.scrollIntoView({ block: 'start', behavior: 'auto' })
|
||||
}
|
||||
@@ -3637,7 +3637,7 @@ var htmx = (function() {
|
||||
handleTriggerHeader(xhr, 'HX-Trigger-After-Settle', finalElt)
|
||||
}
|
||||
maybeCall(settleResolve)
|
||||
},
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
triggerErrorEvent(elt, 'htmx:swapError', responseInfo)
|
||||
|
||||
@@ -378,29 +378,29 @@ describe('Core htmx API test', function() {
|
||||
|
||||
it('swaps content properly (basic)', function() {
|
||||
var output = make('<output id="output"/>')
|
||||
htmx.swap('#output', '<div>Swapped!</div>', {swapStyle: 'innerHTML'});
|
||||
output.innerHTML.should.be.equal('<div>Swapped!</div>');
|
||||
htmx.swap('#output', '<div>Swapped!</div>', { swapStyle: 'innerHTML' })
|
||||
output.innerHTML.should.be.equal('<div>Swapped!</div>')
|
||||
})
|
||||
|
||||
it('swaps content properly (with select)', function() {
|
||||
var output = make('<output id="output"/>')
|
||||
htmx.swap('#output', '<div><p id="select-me">Swapped!</p></div>', {swapStyle: 'innerHTML'}, {select: '#select-me'});
|
||||
output.innerHTML.should.be.equal('<p id="select-me">Swapped!</p>');
|
||||
htmx.swap('#output', '<div><p id="select-me">Swapped!</p></div>', { swapStyle: 'innerHTML' }, { select: '#select-me' })
|
||||
output.innerHTML.should.be.equal('<p id="select-me">Swapped!</p>')
|
||||
})
|
||||
|
||||
it('swaps content properly (with oob)', function() {
|
||||
var output = make('<output id="output"/>')
|
||||
var oobDiv = make('<div id="oob"/>')
|
||||
htmx.swap('#output', '<div id="oob" hx-swap-oob="innerHTML">OOB Swapped!</div><div>Swapped!</div>', {swapStyle: 'innerHTML'});
|
||||
output.innerHTML.should.be.equal('<div>Swapped!</div>');
|
||||
oobDiv.innerHTML.should.be.equal('OOB Swapped!');
|
||||
htmx.swap('#output', '<div id="oob" hx-swap-oob="innerHTML">OOB Swapped!</div><div>Swapped!</div>', { swapStyle: 'innerHTML' })
|
||||
output.innerHTML.should.be.equal('<div>Swapped!</div>')
|
||||
oobDiv.innerHTML.should.be.equal('OOB Swapped!')
|
||||
})
|
||||
|
||||
it('swaps content properly (with select oob)', function() {
|
||||
var output = make('<output id="output"/>')
|
||||
var oobDiv = make('<div id="oob"/>')
|
||||
htmx.swap('#output', '<div id="oob">OOB Swapped!</div><div>Swapped!</div>', {swapStyle: 'innerHTML'}, {selectOOB: '#oob:innerHTML'});
|
||||
output.innerHTML.should.be.equal('<div>Swapped!</div>');
|
||||
oobDiv.innerHTML.should.be.equal('OOB Swapped!');
|
||||
htmx.swap('#output', '<div id="oob">OOB Swapped!</div><div>Swapped!</div>', { swapStyle: 'innerHTML' }, { selectOOB: '#oob:innerHTML' })
|
||||
output.innerHTML.should.be.equal('<div>Swapped!</div>')
|
||||
oobDiv.innerHTML.should.be.equal('OOB Swapped!')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user