mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-29 22:11:22 +00:00
Merge branch 'master' into dev
# Conflicts: # www/attributes/hx-target.md # www/css/site.css # www/reference.md # www/themes/htmx-theme/templates/base.html
This commit is contained in:
commit
56ed5696e6
@ -155,6 +155,10 @@ This extension adds support for Server Sent Events to htmx. See /www/extensions
|
||||
}, timeout);
|
||||
}
|
||||
};
|
||||
|
||||
source.onopen = function (evt) {
|
||||
api.triggerEvent(elt, "htmx::sseOpen", {source: source});
|
||||
}
|
||||
|
||||
// Add message handlers for every `sse-swap` attribute
|
||||
queryAttributeOnThisOrChildren(elt, "sse-swap").forEach(function(child) {
|
||||
|
23
src/htmx.js
23
src/htmx.js
@ -433,6 +433,23 @@ return (function () {
|
||||
}
|
||||
}
|
||||
|
||||
function normalizePath(path) {
|
||||
try {
|
||||
var url = new URL(path);
|
||||
if (url) {
|
||||
path = url.pathname + url.search;
|
||||
}
|
||||
// remove trailing slash, unless index page
|
||||
if (!path.match('^/$')) {
|
||||
path = path.replace(/\/+$/, '');
|
||||
}
|
||||
return path;
|
||||
} catch (e) {
|
||||
// be kind to IE11, which doesn't support URL()
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
// public API
|
||||
//==========================================================================================
|
||||
@ -1301,7 +1318,7 @@ return (function () {
|
||||
var verb, path;
|
||||
if (elt.tagName === "A") {
|
||||
verb = "get";
|
||||
path = getRawAttribute(elt, 'href');
|
||||
path = elt.href; // DOM property gives the fully resolved href of a relative link
|
||||
} else {
|
||||
var rawAttribute = getRawAttribute(elt, "method");
|
||||
verb = rawAttribute ? rawAttribute.toLowerCase() : "get";
|
||||
@ -2037,6 +2054,8 @@ return (function () {
|
||||
return;
|
||||
}
|
||||
|
||||
url = normalizePath(url);
|
||||
|
||||
var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
|
||||
for (var i = 0; i < historyCache.length; i++) {
|
||||
if (historyCache[i].url === url) {
|
||||
@ -2066,6 +2085,8 @@ return (function () {
|
||||
return null;
|
||||
}
|
||||
|
||||
url = normalizePath(url);
|
||||
|
||||
var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
|
||||
for (var i = 0; i < historyCache.length; i++) {
|
||||
if (historyCache[i].url === url) {
|
||||
|
@ -100,7 +100,8 @@ describe("hx-disinherit attribute", function() {
|
||||
var div = make('<div hx-boost="true" hx-disinherit="false"><a id="a1" href="/test">Click me</a></div>');
|
||||
var link = byId("a1");
|
||||
link.click();
|
||||
should.equal(request.detail.requestConfig.path, '/test');
|
||||
// should match the fully resolved href of the boosted element
|
||||
should.equal(request.detail.requestConfig.path, request.detail.elt.href);
|
||||
should.equal(request.detail.elt["htmx-internal-data"].boosted, true);
|
||||
} finally {
|
||||
htmx.off("htmx:beforeRequest", handler);
|
||||
|
@ -13,7 +13,6 @@
|
||||
<script src="/js/class-tools.js"></script>
|
||||
<script src="/js/preload.js"></script>
|
||||
<script src="/js/_hyperscript.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css">
|
||||
<meta name="generator" content="Zola v.TODO">
|
||||
</head>
|
||||
<body hx-ext="class-tools, preload">
|
||||
@ -50,12 +49,11 @@
|
||||
<div>
|
||||
<a href="/essays/">essays</a>
|
||||
</div>
|
||||
<div>
|
||||
<input _="on keyup[key is 'Escape'] or click elsewhere
|
||||
blur() then set my.value to ''
|
||||
on keyup[key is '/'] from <body/>
|
||||
focus()"
|
||||
placeholder="🔍" type="text" id="search"/>
|
||||
<div hx-disable>
|
||||
<form action="https://google.com/search">
|
||||
<input type="hidden" name="q" value="site:htmx.org">
|
||||
<label><span style="display:none;">Search</span><input type="text" name="q" placeholder="🔍️" class="search-box"></label>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="github-stars">
|
||||
@ -118,13 +116,5 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
|
||||
<script type="text/javascript"> docsearch({
|
||||
apiKey: '47070108e6ce8dfee6beee94b83bee7d',
|
||||
indexName: 'htmx',
|
||||
inputSelector: '#search',
|
||||
debug: false // Set debug to true if you want to inspect the dropdown
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user