summaryrefslogtreecommitdiffstatshomepage
path: root/test/core
diff options
context:
space:
mode:
authorCarson Gross <carson@bigsky.software>2024-03-01 15:50:21 -0700
committerCarson Gross <carson@bigsky.software>2024-03-01 15:50:21 -0700
commit9431183cf1cccaa0e0cd1a60d280a3b1cc99b62b (patch)
tree8f43a918aa32b07a43a0dffb0cd2611ee5c0fea1 /test/core
parent13ff1963b56fda70680c8ce45b17c0f1f9642370 (diff)
downloadhtmx-9431183cf1cccaa0e0cd1a60d280a3b1cc99b62b.tar.gz
htmx-9431183cf1cccaa0e0cd1a60d280a3b1cc99b62b.zip
port back double exec tests from 2.x to ensure its not an issue in 1.x, bump version
Diffstat (limited to 'test/core')
-rw-r--r--test/core/regressions.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/core/regressions.js b/test/core/regressions.js
index a0f6724e..8f844cfb 100644
--- a/test/core/regressions.js
+++ b/test/core/regressions.js
@@ -212,4 +212,37 @@ describe("Core htmx Regression Tests", function(){
var input = byId("id_email");
input.value.should.equal("supertest@test.com");
});
+
+ it("script tags only execute once", function(done) {
+ window.i = 0; // set count to 0
+ this.server.respondWith('GET', '/test', '<script>console.trace(); window.i++</script>') // increment the count by 1
+
+ // make a div w/ a short settle delay to make the problem more obvious
+ var div = make('<div hx-get="/test" hx-swap="innerHTML settle:5ms"/>');
+ div.click();
+ this.server.respond()
+
+ setTimeout(function(){
+ window.i.should.equal(1);
+ delete window.i;
+ done();
+ }, 50)
+ })
+
+ it("script tags only execute once when nested", function(done) {
+ window.i = 0; // set count to 0
+ this.server.respondWith('GET', '/test', '<p>foo</p><div><script>console.trace(); window.i++</script></div>') // increment the count by 1
+
+ // make a div w/ a short settle delay to make the problem more obvious
+ var div = make('<div hx-get="/test" hx-swap="innerHTML settle:5ms"/>');
+ div.click();
+ this.server.respond()
+
+ setTimeout(function(){
+ window.i.should.equal(1);
+ delete window.i;
+ done();
+ }, 50)
+ })
+
});