Skip to content

Commit

Permalink
remove hack to clear content on empty result, since it didn't work we…
Browse files Browse the repository at this point in the history
…ll with client-side-templates extension etc
  • Loading branch information
jyrimatti committed Oct 9, 2024
1 parent 6f56e0a commit ecb12a2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Extension to use SQLite database backend for Htmx over:
evt.detail.xhr = {
status: 200,
getAllResponseHeaders: function() {
return this.getResponseHeader("Content-Type:application/json");
return "Content-Type:application/json";
},
getResponseHeader: function(headerName) {
if (headerName.toLowerCase() === "content-type") {
Expand Down Expand Up @@ -128,7 +128,7 @@ Extension to use SQLite database backend for Htmx over:
});

evt.detail.xhr.responseJSON = allRows;
evt.detail.xhr.response = allRows.length == 0 ? '' : JSON.stringify(allRows);
evt.detail.xhr.response = JSON.stringify(allRows);
onload();
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/sqlite.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "htmx-sqlite",
"version": "1.9.0",
"version": "1.9.1",
"description": "Htmx extension to use SQLite database backend over HTTP or OPFS",
"author": "Jyri-Matti Lähteenmäki <[email protected]>",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Extension to use SQLite database backend for Htmx over:
evt.detail.xhr = {
status: 200,
getAllResponseHeaders: function() {
return this.getResponseHeader("Content-Type:application/json");
return "Content-Type:application/json";
},
getResponseHeader: function(headerName) {
if (headerName.toLowerCase() === "content-type") {
Expand Down Expand Up @@ -128,7 +128,7 @@ Extension to use SQLite database backend for Htmx over:
});

evt.detail.xhr.responseJSON = allRows;
evt.detail.xhr.response = allRows.length == 0 ? '' : JSON.stringify(allRows);
evt.detail.xhr.response = JSON.stringify(allRows);
onload();
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("sqlite extension", function() {
it('empty result clears content', function (done) {
var div = make('<div hx-trigger="load" hx-get="SELECT * FROM mytable"></div>');
div.addEventListener('htmx:afterSwap', () => {
div.innerText.should.equal('');
div.innerText.should.equal('[]');
done();
});
});
Expand Down

0 comments on commit ecb12a2

Please sign in to comment.