Skip to content

Commit

Permalink
prep 1.9.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
1cg committed Apr 26, 2023
1 parent c98e254 commit 7704d4d
Show file tree
Hide file tree
Showing 207 changed files with 123,302 additions and 26 deletions.
4 changes: 4 additions & 0 deletions dist/ext/sse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
53 changes: 40 additions & 13 deletions dist/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ return (function () {
sock.binaryType = htmx.config.wsBinaryType;
return sock;
},
version: "1.9.0"
version: "1.9.1"
};

/** @type {import("./htmx").HtmxInternalApi} */
Expand Down Expand Up @@ -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
//==========================================================================================
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -1722,13 +1739,6 @@ return (function () {
});
}
});
if (!explicitAction && hasAttribute(elt, 'hx-trigger')) {
explicitAction = true
triggerSpecs.forEach(function(triggerSpec) {
// For "naked" triggers, don't do anything at all
addTriggerHandler(elt, triggerSpec, nodeData, function () { })
})
}
return explicitAction;
}

Expand Down Expand Up @@ -1913,10 +1923,18 @@ return (function () {
}

var triggerSpecs = getTriggerSpecs(elt);
var explicitAction = processVerbs(elt, nodeData, triggerSpecs);

if (!explicitAction && getClosestAttributeValue(elt, "hx-boost") === "true") {
boostElement(elt, nodeData, triggerSpecs);
var hasExplicitHttpAction = processVerbs(elt, nodeData, triggerSpecs);

if (!hasExplicitHttpAction) {
if (getClosestAttributeValue(elt, "hx-boost") === "true") {
boostElement(elt, nodeData, triggerSpecs);
} else if (hasAttribute(elt, 'hx-trigger')) {
triggerSpecs.forEach(function (triggerSpec) {
// For "naked" triggers, don't do anything at all
addTriggerHandler(elt, triggerSpec, nodeData, function () {
})
})
}
}

if (elt.tagName === "FORM") {
Expand Down Expand Up @@ -2037,6 +2055,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) {
Expand Down Expand Up @@ -2066,6 +2086,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) {
Expand Down Expand Up @@ -3515,6 +3537,7 @@ return (function () {
internalData.xhr.abort();
}
});
var originalPopstate = window.onpopstate;
window.onpopstate = function (event) {
if (event.state && event.state.htmx) {
restoreHistory();
Expand All @@ -3524,6 +3547,10 @@ return (function () {
'triggerEvent': triggerEvent
});
});
} else {
if (originalPopstate) {
originalPopstate(event);
}
}
};
setTimeout(function () {
Expand Down
2 changes: 1 addition & 1 deletion dist/htmx.min.js

Large diffs are not rendered by default.

Binary file modified dist/htmx.min.js.gz
Binary file not shown.

0 comments on commit 7704d4d

Please sign in to comment.