mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 07:21:05 +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);
|
}, timeout);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
source.onopen = function (evt) {
|
||||||
|
api.triggerEvent(elt, "htmx::sseOpen", {source: source});
|
||||||
|
}
|
||||||
|
|
||||||
// Add message handlers for every `sse-swap` attribute
|
// Add message handlers for every `sse-swap` attribute
|
||||||
queryAttributeOnThisOrChildren(elt, "sse-swap").forEach(function(child) {
|
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
|
// public API
|
||||||
//==========================================================================================
|
//==========================================================================================
|
||||||
@ -1301,7 +1318,7 @@ return (function () {
|
|||||||
var verb, path;
|
var verb, path;
|
||||||
if (elt.tagName === "A") {
|
if (elt.tagName === "A") {
|
||||||
verb = "get";
|
verb = "get";
|
||||||
path = getRawAttribute(elt, 'href');
|
path = elt.href; // DOM property gives the fully resolved href of a relative link
|
||||||
} else {
|
} else {
|
||||||
var rawAttribute = getRawAttribute(elt, "method");
|
var rawAttribute = getRawAttribute(elt, "method");
|
||||||
verb = rawAttribute ? rawAttribute.toLowerCase() : "get";
|
verb = rawAttribute ? rawAttribute.toLowerCase() : "get";
|
||||||
@ -2037,6 +2054,8 @@ return (function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url = normalizePath(url);
|
||||||
|
|
||||||
var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
|
var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
|
||||||
for (var i = 0; i < historyCache.length; i++) {
|
for (var i = 0; i < historyCache.length; i++) {
|
||||||
if (historyCache[i].url === url) {
|
if (historyCache[i].url === url) {
|
||||||
@ -2066,6 +2085,8 @@ return (function () {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url = normalizePath(url);
|
||||||
|
|
||||||
var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
|
var historyCache = parseJSON(localStorage.getItem("htmx-history-cache")) || [];
|
||||||
for (var i = 0; i < historyCache.length; i++) {
|
for (var i = 0; i < historyCache.length; i++) {
|
||||||
if (historyCache[i].url === url) {
|
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 div = make('<div hx-boost="true" hx-disinherit="false"><a id="a1" href="/test">Click me</a></div>');
|
||||||
var link = byId("a1");
|
var link = byId("a1");
|
||||||
link.click();
|
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);
|
should.equal(request.detail.elt["htmx-internal-data"].boosted, true);
|
||||||
} finally {
|
} finally {
|
||||||
htmx.off("htmx:beforeRequest", handler);
|
htmx.off("htmx:beforeRequest", handler);
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
<script src="/js/class-tools.js"></script>
|
<script src="/js/class-tools.js"></script>
|
||||||
<script src="/js/preload.js"></script>
|
<script src="/js/preload.js"></script>
|
||||||
<script src="/js/_hyperscript.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">
|
<meta name="generator" content="Zola v.TODO">
|
||||||
</head>
|
</head>
|
||||||
<body hx-ext="class-tools, preload">
|
<body hx-ext="class-tools, preload">
|
||||||
@ -50,12 +49,11 @@
|
|||||||
<div>
|
<div>
|
||||||
<a href="/essays/">essays</a>
|
<a href="/essays/">essays</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div hx-disable>
|
||||||
<input _="on keyup[key is 'Escape'] or click elsewhere
|
<form action="https://google.com/search">
|
||||||
blur() then set my.value to ''
|
<input type="hidden" name="q" value="site:htmx.org">
|
||||||
on keyup[key is '/'] from <body/>
|
<label><span style="display:none;">Search</span><input type="text" name="q" placeholder="🔍️" class="search-box"></label>
|
||||||
focus()"
|
</form>
|
||||||
placeholder="🔍" type="text" id="search"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="github-stars">
|
<div class="github-stars">
|
||||||
@ -118,13 +116,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</footer>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user