mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-10-28 08:25:24 +08:00
rebuild dist for 2.0.11
This commit is contained in:
1 parent
be73c920f5
commit
fa978b24e7
19 files changed
+59
-53
No files matched your search
@@ -33,7 +33,7 @@ By removing these arbitrary constraints htmx completes HTML as a
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js"
|
||||
integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b"
|
||||
integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg"
|
||||
crossorigin="anonymous"></script>
|
||||
<!-- have a button POST a click via AJAX -->
|
||||
<button hx-post="/clicked" hx-swap="outerHTML">
|
||||
|
||||
Vendored
+7
-6
@@ -576,6 +576,11 @@ var htmx = (function() {
|
||||
* @param {DocumentFragment} fragment
|
||||
*/
|
||||
function normalizeScriptTags(fragment) {
|
||||
if (!htmx.config.allowScriptTags) {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
return
|
||||
}
|
||||
Array.from(fragment.querySelectorAll('script')).forEach(/** @param {HTMLScriptElement} script */ (script) => {
|
||||
if (isJavaScriptScriptNode(script)) {
|
||||
const newScript = duplicateScript(script)
|
||||
@@ -636,12 +641,7 @@ var htmx = (function() {
|
||||
}
|
||||
}
|
||||
if (fragment) {
|
||||
if (htmx.config.allowScriptTags) {
|
||||
normalizeScriptTags(fragment)
|
||||
} else {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
}
|
||||
normalizeScriptTags(fragment)
|
||||
}
|
||||
return fragment
|
||||
}
|
||||
@@ -1868,6 +1868,7 @@ var htmx = (function() {
|
||||
target = asElement(target)
|
||||
if (target) {
|
||||
var fragment = template.content.cloneNode(true)
|
||||
normalizeScriptTags(fragment)
|
||||
var beforeSwapDetails = { shouldSwap: true, target, fragment }
|
||||
if (!triggerEvent(target, 'htmx:partialBeforeSwap', beforeSwapDetails)) return
|
||||
target = beforeSwapDetails.target
|
||||
|
||||
Vendored
+7
-6
@@ -575,6 +575,11 @@ var htmx = (function() {
|
||||
* @param {DocumentFragment} fragment
|
||||
*/
|
||||
function normalizeScriptTags(fragment) {
|
||||
if (!htmx.config.allowScriptTags) {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
return
|
||||
}
|
||||
Array.from(fragment.querySelectorAll('script')).forEach(/** @param {HTMLScriptElement} script */ (script) => {
|
||||
if (isJavaScriptScriptNode(script)) {
|
||||
const newScript = duplicateScript(script)
|
||||
@@ -635,12 +640,7 @@ var htmx = (function() {
|
||||
}
|
||||
}
|
||||
if (fragment) {
|
||||
if (htmx.config.allowScriptTags) {
|
||||
normalizeScriptTags(fragment)
|
||||
} else {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
}
|
||||
normalizeScriptTags(fragment)
|
||||
}
|
||||
return fragment
|
||||
}
|
||||
@@ -1867,6 +1867,7 @@ var htmx = (function() {
|
||||
target = asElement(target)
|
||||
if (target) {
|
||||
var fragment = template.content.cloneNode(true)
|
||||
normalizeScriptTags(fragment)
|
||||
var beforeSwapDetails = { shouldSwap: true, target, fragment }
|
||||
if (!triggerEvent(target, 'htmx:partialBeforeSwap', beforeSwapDetails)) return
|
||||
target = beforeSwapDetails.target
|
||||
|
||||
Vendored
+7
-6
@@ -575,6 +575,11 @@ var htmx = (function() {
|
||||
* @param {DocumentFragment} fragment
|
||||
*/
|
||||
function normalizeScriptTags(fragment) {
|
||||
if (!htmx.config.allowScriptTags) {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
return
|
||||
}
|
||||
Array.from(fragment.querySelectorAll('script')).forEach(/** @param {HTMLScriptElement} script */ (script) => {
|
||||
if (isJavaScriptScriptNode(script)) {
|
||||
const newScript = duplicateScript(script)
|
||||
@@ -635,12 +640,7 @@ var htmx = (function() {
|
||||
}
|
||||
}
|
||||
if (fragment) {
|
||||
if (htmx.config.allowScriptTags) {
|
||||
normalizeScriptTags(fragment)
|
||||
} else {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
}
|
||||
normalizeScriptTags(fragment)
|
||||
}
|
||||
return fragment
|
||||
}
|
||||
@@ -1867,6 +1867,7 @@ var htmx = (function() {
|
||||
target = asElement(target)
|
||||
if (target) {
|
||||
var fragment = template.content.cloneNode(true)
|
||||
normalizeScriptTags(fragment)
|
||||
var beforeSwapDetails = { shouldSwap: true, target, fragment }
|
||||
if (!triggerEvent(target, 'htmx:partialBeforeSwap', beforeSwapDetails)) return
|
||||
target = beforeSwapDetails.target
|
||||
|
||||
Vendored
+7
-6
@@ -575,6 +575,11 @@ var htmx = (function() {
|
||||
* @param {DocumentFragment} fragment
|
||||
*/
|
||||
function normalizeScriptTags(fragment) {
|
||||
if (!htmx.config.allowScriptTags) {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
return
|
||||
}
|
||||
Array.from(fragment.querySelectorAll('script')).forEach(/** @param {HTMLScriptElement} script */ (script) => {
|
||||
if (isJavaScriptScriptNode(script)) {
|
||||
const newScript = duplicateScript(script)
|
||||
@@ -635,12 +640,7 @@ var htmx = (function() {
|
||||
}
|
||||
}
|
||||
if (fragment) {
|
||||
if (htmx.config.allowScriptTags) {
|
||||
normalizeScriptTags(fragment)
|
||||
} else {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
}
|
||||
normalizeScriptTags(fragment)
|
||||
}
|
||||
return fragment
|
||||
}
|
||||
@@ -1867,6 +1867,7 @@ var htmx = (function() {
|
||||
target = asElement(target)
|
||||
if (target) {
|
||||
var fragment = template.content.cloneNode(true)
|
||||
normalizeScriptTags(fragment)
|
||||
var beforeSwapDetails = { shouldSwap: true, target, fragment }
|
||||
if (!triggerEvent(target, 'htmx:partialBeforeSwap', beforeSwapDetails)) return
|
||||
target = beforeSwapDetails.target
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
var htmx=function(){"use strict";const Y={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=pn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true,historyRestoreAsHxRequest:true,reportValidityOfForms:false},parseInterval:null,location:location,_:null,version:"2.0.11"};Y.onLoad=V;Y.process=Bt;Y.on=ye;Y.off=xe;Y.trigger=ae;Y.ajax=In;Y.find=a;Y.findAll=x;Y.closest=g;Y.remove=z;Y.addClass=w;Y.removeClass=S;Y.toggleClass=G;Y.takeClass=W;Y.swap=C;Y.defineExtension=zn;Y.removeExtension=Jn;Y.logAll=$;Y.logNone=_;Y.parseInterval=d;Y._=e;const n={addTriggerHandler:Et,bodyContains:ie,canAccessLocalStorage:U,findThisElement:we,filterValues:xn,swap:C,hasAttribute:s,getAttributeValue:f,getClosestAttributeValue:te,getClosestMatch:A,getExpressionVars:qn,getHeaders:yn,getInputValues:pn,getInternalData:re,getSwapSpecification:vn,getTriggerSpecs:lt,getTarget:Se,makeFragment:D,mergeObjects:se,makeSettleInfo:En,oobSwap:Te,querySelectorExt:ce,settleImmediately:Qt,shouldCancel:dt,triggerEvent:ae,triggerErrorEvent:ue,withExtensions:Vt};const he=["get","post","put","delete","patch"];const R=he.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function Q(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function f(e,t){return Q(e,t)||Q(e,"data-"+t)}function u(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function ee(){return document}function q(e,t){return e.getRootNode?e.getRootNode({composed:t}):ee()}function A(e,t){while(e&&!t(e)){e=u(e)}return e||null}function o(e,t,n){const r=f(t,n);const o=f(t,"hx-disinherit");var i=f(t,"hx-inherit");if(e!==t){if(Y.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function te(t,n){let r=null;A(t,function(e){return!!(r=o(t,le(e),n))});if(r!=="unset"){return r}}function h(e,t){return e instanceof Element&&e.matches(t)}function N(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function I(e){if("parseHTMLUnsafe"in Document){return Document.parseHTMLUnsafe(e)}const t=new DOMParser;return t.parseFromString(e,"text/html")}function L(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function r(e){const t=ee().createElement("script");oe(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Y.config.inlineScriptNonce){t.nonce=Y.config.inlineScriptNonce}return t}function i(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function k(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(i(e)){const t=r(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){T(e)}finally{e.remove()}}})}function D(e){e=e.replace(/<hx-([a-z]+)((?:\s[^>]*)?)>/gi,'<template hx type="$1"$2>').replace(/<\/hx-[a-z]+>/gi,"</template>");const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,"");const n=N(t);let r;if(n==="html"){r=new DocumentFragment;const i=I(e);L(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=I(t);L(r,i.body);r.title=i.title}else{const i=I('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Y.config.allowScriptTags){k(r)}else{r.querySelectLine truncated
|
||||
var htmx=function(){"use strict";const Y={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=pn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true,historyRestoreAsHxRequest:true,reportValidityOfForms:false},parseInterval:null,location:location,_:null,version:"2.0.11"};Y.onLoad=V;Y.process=Bt;Y.on=ye;Y.off=xe;Y.trigger=ae;Y.ajax=In;Y.find=a;Y.findAll=x;Y.closest=g;Y.remove=z;Y.addClass=w;Y.removeClass=S;Y.toggleClass=G;Y.takeClass=W;Y.swap=C;Y.defineExtension=zn;Y.removeExtension=Jn;Y.logAll=$;Y.logNone=_;Y.parseInterval=d;Y._=e;const n={addTriggerHandler:Et,bodyContains:ie,canAccessLocalStorage:U,findThisElement:we,filterValues:xn,swap:C,hasAttribute:s,getAttributeValue:f,getClosestAttributeValue:te,getClosestMatch:A,getExpressionVars:qn,getHeaders:yn,getInputValues:pn,getInternalData:re,getSwapSpecification:vn,getTriggerSpecs:lt,getTarget:Se,makeFragment:D,mergeObjects:se,makeSettleInfo:En,oobSwap:Te,querySelectorExt:ce,settleImmediately:Qt,shouldCancel:dt,triggerEvent:ae,triggerErrorEvent:ue,withExtensions:Vt};const he=["get","post","put","delete","patch"];const R=he.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function Q(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function f(e,t){return Q(e,t)||Q(e,"data-"+t)}function u(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function ee(){return document}function q(e,t){return e.getRootNode?e.getRootNode({composed:t}):ee()}function A(e,t){while(e&&!t(e)){e=u(e)}return e||null}function o(e,t,n){const r=f(t,n);const o=f(t,"hx-disinherit");var i=f(t,"hx-inherit");if(e!==t){if(Y.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function te(t,n){let r=null;A(t,function(e){return!!(r=o(t,le(e),n))});if(r!=="unset"){return r}}function h(e,t){return e instanceof Element&&e.matches(t)}function N(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function I(e){if("parseHTMLUnsafe"in Document){return Document.parseHTMLUnsafe(e)}const t=new DOMParser;return t.parseFromString(e,"text/html")}function L(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function r(e){const t=ee().createElement("script");oe(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Y.config.inlineScriptNonce){t.nonce=Y.config.inlineScriptNonce}return t}function i(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function k(e){if(!Y.config.allowScriptTags){e.querySelectorAll("script").forEach(e=>e.remove());return}Array.from(e.querySelectorAll("script")).forEach(e=>{if(i(e)){const t=r(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){T(e)}finally{e.remove()}}})}function D(e){e=e.replace(/<hx-([a-z]+)((?:\s[^>]*)?)>/gi,'<template hx type="$1"$2>').replace(/<\/hx-[a-z]+>/gi,"</template>");const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,"");const n=N(t);let r;if(n==="html"){r=new DocumentFragment;const i=I(e);L(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=I(t);L(r,i.body);r.title=i.title}else{const i=I('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){oLine truncated
|
||||
Vendored
BIN
Binary file not shown.
@@ -42,7 +42,7 @@
|
||||
},
|
||||
{
|
||||
"name": "hx-disabled-elt",
|
||||
"description": "The `hx-disabled-elt` attribute allows you to specify elements that will have the `disabled` attribute\nadded to them for the duration of the request. The value of this attribute can be:\n\n* A CSS query selector of the element to disable.\n* `this` to disable the element itself\n* `closest <CSS selector>` which will find the [closest](https://developer.mozilla.org/docs/Web/API/Element/closest)\n ancestor element or itself, that matches the given CSS selector\n (e.g. `closest fieldset` will disable the closest to the element `fieldset`).\n* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector\n* `next` which resolves to [element.nextElementSibling](https://developer.mozilla.org/docs/Web/API/Element/nextElementSibling)\n* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector\n (e.g. `next button` will disable the closest following sibling `button` element)\n* `previous` which resolves to [element.previousElementSibling](https://developer.mozilla.org/docs/Web/API/Element/previousElementSibling)\n* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.\n (e.g. `previous input` will disable the closest previous sibling `input` element)",
|
||||
"description": "The `hx-disabled-elt` attribute allows you to specify elements that will have the `disabled` attribute\nadded to them for the duration of the request. The value of this attribute can be:\n\n* A CSS query selector of the elements to disable.\n* `this` to disable the element itself\n* `closest <CSS selector>` which will find the [closest](https://developer.mozilla.org/docs/Web/API/Element/closest)\n ancestor element or itself, that matches the given CSS selector\n (e.g. `closest fieldset` will disable the closest to the element `fieldset`).\n* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector\n* `next` which resolves to [element.nextElementSibling](https://developer.mozilla.org/docs/Web/API/Element/nextElementSibling)\n* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector\n (e.g. `next button` will disable the first `button` element that follows this element in the document)\n* `previous` which resolves to [element.previousElementSibling](https://developer.mozilla.org/docs/Web/API/Element/previousElementSibling)\n* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.\n (e.g. `previous input` will disable the first `input` element that precedes this element in the document)",
|
||||
"description-sections": {
|
||||
"Inherited": ""
|
||||
},
|
||||
@@ -100,7 +100,7 @@
|
||||
},
|
||||
{
|
||||
"name": "hx-include",
|
||||
"description": "The `hx-include` attribute allows you to include additional element values in an AJAX request. The value of this\nattribute can be:\n\n* A CSS query selector of the elements to include.\n* `this` which will include the descendants of the element.\n* `closest <CSS selector>` which will find the [closest](https://developer.mozilla.org/docs/Web/API/Element/closest)\n ancestor element or itself, that matches the given CSS selector\n (e.g. `closest tr` will target the closest table row to the element).\n* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector.\n* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector.\n (e.g. `next .error` will target the closest following sibling element with `error` class)\n* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.\n (e.g. `previous .error` will target the closest previous sibling with `error` class)",
|
||||
"description": "The `hx-include` attribute allows you to include additional element values in an AJAX request. The value of this\nattribute can be:\n\n* A CSS query selector of the elements to include.\n* `this` which will include the descendants of the element.\n* `closest <CSS selector>` which will find the [closest](https://developer.mozilla.org/docs/Web/API/Element/closest)\n ancestor element or itself, that matches the given CSS selector\n (e.g. `closest tr` will target the closest table row to the element).\n* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector.\n* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector.\n (e.g. `next .error` will target the first element with the `error` class that follows this element in the document)\n* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.\n (e.g. `previous .error` will target the first element with the `error` class that precedes this element in the document)",
|
||||
"description-sections": {
|
||||
"Inherited": ""
|
||||
},
|
||||
@@ -268,7 +268,7 @@
|
||||
},
|
||||
{
|
||||
"name": "hx-target",
|
||||
"description": "The `hx-target` attribute allows you to target a different element for swapping than the one issuing the AJAX\nrequest. The value of this attribute can be:\n\n* A CSS query selector of the element to target.\n* `this` which indicates that the element that the `hx-target` attribute is on is the target.\n* `closest <CSS selector>` which will find the [closest](https://developer.mozilla.org/docs/Web/API/Element/closest)\n ancestor element or itself, that matches the given CSS selector\n (e.g. `closest tr` will target the closest table row to the element).\n* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector.\n* `next` which resolves to [element.nextElementSibling](https://developer.mozilla.org/docs/Web/API/Element/nextElementSibling)\n* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector.\n (e.g. `next .error` will target the closest following sibling element with `error` class)\n* `previous` which resolves to [element.previousElementSibling](https://developer.mozilla.org/docs/Web/API/Element/previousElementSibling)\n* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.\n (e.g. `previous .error` will target the closest previous sibling with `error` class)",
|
||||
"description": "The `hx-target` attribute allows you to target a different element for swapping than the one issuing the AJAX\nrequest. The value of this attribute can be:\n\n* A CSS query selector of the element to target.\n* `this` which indicates that the element that the `hx-target` attribute is on is the target.\n* `closest <CSS selector>` which will find the [closest](https://developer.mozilla.org/docs/Web/API/Element/closest)\n ancestor element or itself, that matches the given CSS selector\n (e.g. `closest tr` will target the closest table row to the element).\n* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector.\n* `next` which resolves to [element.nextElementSibling](https://developer.mozilla.org/docs/Web/API/Element/nextElementSibling)\n* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector.\n (e.g. `next .error` will target the first element with the `error` class that follows this element in the document)\n* `previous` which resolves to [element.previousElementSibling](https://developer.mozilla.org/docs/Web/API/Element/previousElementSibling)\n* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.\n (e.g. `previous .error` will target the first element with the `error` class that precedes this element in the document)",
|
||||
"description-sections": {
|
||||
"Inherited": ""
|
||||
},
|
||||
@@ -372,7 +372,7 @@
|
||||
},
|
||||
{
|
||||
"name": "afterRequest",
|
||||
"description": "This event is triggered after an AJAX request has finished either in the case of a successful request (although\none that may have returned a remote error code such as a `404`) or in a network error situation. This event\ncan be paired with [`htmx:beforeRequest`](#htmx:beforeRequest) to wrap behavior around a request cycle.\n\n##### Details\n\n* `detail.elt` - the element that dispatched the request or if the body no longer contains the element then the closest parent\n* `detail.xhr` - the `XMLHttpRequest`\n* `detail.target` - the target of the request\n* `detail.requestConfig` - the configuration of the AJAX request\n* `detail.successful` - true if the response has a 20x status code or is marked `detail.isError = false` in the\n `htmx:beforeSwap` event, else false\n* `detail.failed` - true if the response does not have a 20x status code or is marked `detail.isError = true` in the\n `htmx:beforeSwap` event, else false\n\n",
|
||||
"description": "This event is triggered after an AJAX request has finished either in the case of a successful request (although\none that may have returned a remote error code such as a `404`) or in a network error situation. This event\ncan be paired with [`htmx:beforeRequest`](#htmx:beforeRequest) to wrap behavior around a request cycle.\n\n##### Details\n\n* `detail.elt` - the element that dispatched the request or if the body no longer contains the element then the closest parent\n* `detail.xhr` - the `XMLHttpRequest`\n* `detail.target` - the target of the request\n* `detail.requestConfig` - the configuration of the AJAX request\n* `detail.successful` - true if the matched [`htmx.config.responseHandling`](@/docs.md#response-handling) rule did not\n mark the response as an error (by default, 2xx and 3xx codes), or `detail.isError` was set to `false` in the\n `htmx:beforeSwap` event\n* `detail.failed` - the inverse of `detail.successful`\n\n",
|
||||
"doc-url": "https://htmx.org/events/#htmx:afterRequest"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -124,7 +124,7 @@ By removing these constraints, htmx completes HTML as a [hypertext](https://en.w
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js"
|
||||
integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b"
|
||||
integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg"
|
||||
crossorigin="anonymous"></script>
|
||||
<!-- have a button POST a click via AJAX -->
|
||||
<button hx-post="/clicked" hx-swap="outerHTML">
|
||||
|
||||
+3
-3
@@ -124,13 +124,13 @@ The fastest way to get going with htmx is to load it via a CDN. You can simply a
|
||||
your head tag and get going:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
An unminified version is also available as well:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.js" integrity="sha384-B5zAMqBnEIG1hmhunPVjsg178JllFucV/SuoPIKTWHEoARjXFHcBbsCfNion2SS2" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.js" integrity="sha384-gmJEF2eAKY4e+FDN+qtKIivWyb6ANwDB7JUdUybKgQspPKyEX/pIRZG/0uaRoW2C" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
While the CDN approach is extremely simple, you may want to consider
|
||||
@@ -1164,7 +1164,7 @@ You can see all available extensions on the [Extensions](/extensions) page.
|
||||
The fastest way to install htmx extensions created by others is to load them via a CDN. Remember to always include the core htmx library before the extensions and [enable the extension](#enabling-extensions). For example, if you would like to use the [response-targets](/extensions/response-targets) extension, you can add this to your head tag:
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4" integrity="sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="extension-name">
|
||||
|
||||
@@ -18,7 +18,7 @@ a feature of the library. This extension addresses that shortcoming.
|
||||
The fastest way to install `head-support` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5" integrity="sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="head-support">
|
||||
|
||||
@@ -9,7 +9,7 @@ The `htmx-1-compat` extension allows you to almost seamlessly upgrade from htmx
|
||||
The fastest way to install `htmx-1-compat` is to load it via a CDN. Remember to always include the core htmx library before the extension and enable the extension.
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2" integrity="sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="htmx-1-compat">
|
||||
|
||||
@@ -16,7 +16,7 @@ The fastest way to install `idiomorph` is to load it via a CDN. Remember to alwa
|
||||
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js" integrity="sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="morph">
|
||||
|
||||
@@ -15,7 +15,7 @@ unused requests. Use this extension carefully!
|
||||
The fastest way to install `preload` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2" integrity="sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="preload">
|
||||
|
||||
@@ -27,7 +27,7 @@ The value of each attribute can be:
|
||||
The fastest way to install `response-targets` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4" integrity="sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="response-targets">
|
||||
|
||||
@@ -29,7 +29,7 @@ Use the following attributes to configure how SSE connections behave:
|
||||
The fastest way to install `sse` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4" integrity="sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="sse">
|
||||
|
||||
@@ -23,7 +23,7 @@ Use the following attributes to configure how WebSockets behave:
|
||||
The fastest way to install `ws` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-748snOk79hP4Y80eB711CBgC/j/ujsPDVl9cMdpiXZDYicpBmI2D8w+QlWvMUg2b" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js" integrity="sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4" integrity="sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="ws">
|
||||
|
||||
@@ -575,6 +575,11 @@ var htmx = (function() {
|
||||
* @param {DocumentFragment} fragment
|
||||
*/
|
||||
function normalizeScriptTags(fragment) {
|
||||
if (!htmx.config.allowScriptTags) {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
return
|
||||
}
|
||||
Array.from(fragment.querySelectorAll('script')).forEach(/** @param {HTMLScriptElement} script */ (script) => {
|
||||
if (isJavaScriptScriptNode(script)) {
|
||||
const newScript = duplicateScript(script)
|
||||
@@ -635,12 +640,7 @@ var htmx = (function() {
|
||||
}
|
||||
}
|
||||
if (fragment) {
|
||||
if (htmx.config.allowScriptTags) {
|
||||
normalizeScriptTags(fragment)
|
||||
} else {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
}
|
||||
normalizeScriptTags(fragment)
|
||||
}
|
||||
return fragment
|
||||
}
|
||||
@@ -1867,6 +1867,7 @@ var htmx = (function() {
|
||||
target = asElement(target)
|
||||
if (target) {
|
||||
var fragment = template.content.cloneNode(true)
|
||||
normalizeScriptTags(fragment)
|
||||
var beforeSwapDetails = { shouldSwap: true, target, fragment }
|
||||
if (!triggerEvent(target, 'htmx:partialBeforeSwap', beforeSwapDetails)) return
|
||||
target = beforeSwapDetails.target
|
||||
|
||||
@@ -575,6 +575,11 @@ var htmx = (function() {
|
||||
* @param {DocumentFragment} fragment
|
||||
*/
|
||||
function normalizeScriptTags(fragment) {
|
||||
if (!htmx.config.allowScriptTags) {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
return
|
||||
}
|
||||
Array.from(fragment.querySelectorAll('script')).forEach(/** @param {HTMLScriptElement} script */ (script) => {
|
||||
if (isJavaScriptScriptNode(script)) {
|
||||
const newScript = duplicateScript(script)
|
||||
@@ -635,12 +640,7 @@ var htmx = (function() {
|
||||
}
|
||||
}
|
||||
if (fragment) {
|
||||
if (htmx.config.allowScriptTags) {
|
||||
normalizeScriptTags(fragment)
|
||||
} else {
|
||||
// remove all script tags if scripts are disabled
|
||||
fragment.querySelectorAll('script').forEach((script) => script.remove())
|
||||
}
|
||||
normalizeScriptTags(fragment)
|
||||
}
|
||||
return fragment
|
||||
}
|
||||
@@ -1867,6 +1867,7 @@ var htmx = (function() {
|
||||
target = asElement(target)
|
||||
if (target) {
|
||||
var fragment = template.content.cloneNode(true)
|
||||
normalizeScriptTags(fragment)
|
||||
var beforeSwapDetails = { shouldSwap: true, target, fragment }
|
||||
if (!triggerEvent(target, 'htmx:partialBeforeSwap', beforeSwapDetails)) return
|
||||
target = beforeSwapDetails.target
|
||||
|
||||
Reference in new issue
Block a user