mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-27 04:50:43 +00:00
Fix WebSocket extension trigger handlers initialization (#1468)
* fix websockets initialization to accomodate "haked hx-trigger" * update changelog
This commit is contained in:
parent
81ead8e39a
commit
108d2b458a
@ -1,6 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
## [1.9.3] - 2023-04-28
|
||||
## [1.9.3] - 2023-06-??
|
||||
|
||||
* Fixed bug w/ WebSocket extension initilization caused by "naked" `hx-trigger` feature
|
||||
|
||||
## [1.9.2] - 2023-04-28
|
||||
|
||||
|
@ -52,7 +52,7 @@ This extension adds support for WebSockets to htmx. See /www/extensions/ws.md f
|
||||
return;
|
||||
|
||||
// Try to create websockets when elements are processed
|
||||
case "htmx:afterProcessNode":
|
||||
case "htmx:beforeProcessNode":
|
||||
var parent = evt.target;
|
||||
|
||||
forEach(queryAttributeOnThisOrChildren(parent, "ws-connect"), function (child) {
|
||||
|
@ -77,6 +77,17 @@ describe("web-sockets extension", function () {
|
||||
this.messages.length.should.equal(1);
|
||||
})
|
||||
|
||||
it('sends data to the server with specific trigger', function () {
|
||||
var div = make('<div hx-ext="ws" ws-connect="ws://localhost:8080"><div hx-trigger="click" ws-send id="d1">div1</div></div>');
|
||||
this.tickMock();
|
||||
|
||||
byId("d1").click();
|
||||
|
||||
this.tickMock();
|
||||
|
||||
this.messages.length.should.equal(1);
|
||||
})
|
||||
|
||||
it('handles message from the server', function () {
|
||||
var div = make('<div hx-ext="ws" ws-connect="ws://localhost:8080"><div id="d1">div1</div><div id="d2">div2</div></div>');
|
||||
this.tickMock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user