Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Carson Gross
2024-03-13 17:24:17 -06:00
2 changed files with 43 additions and 7 deletions

8
src/htmx.d.ts vendored
View File

@@ -429,13 +429,7 @@ export interface HtmxConfig {
* If set to true htmx will not update the title of the document when a title tag is found in new content
* @default false
*/
ignoreTitle:? boolean;
/**
* The cache to store evaluated trigger specifications into.
* You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
* @default null
*/
triggerSpecsCache?: {[trigger: string]: HtmxTriggerSpecification[]};
ignoreTitle?: boolean;
}
export type HtmxEvent = "htmx:abort"

View File

@@ -245,4 +245,46 @@ describe("Core htmx Regression Tests", function(){
}, 50)
})
it("script tags only execute once using templates", function(done) {
var oldUseTemplateFragmentsValue = htmx.config.useTemplateFragments
htmx.config.useTemplateFragments = true
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()
htmx.config.useTemplateFragments = oldUseTemplateFragmentsValue
setTimeout(function(){
window.i.should.equal(1);
delete window.i;
done();
}, 50)
})
it("script tags only execute once when nested using templates", function(done) {
var oldUseTemplateFragmentsValue = htmx.config.useTemplateFragments
htmx.config.useTemplateFragments = true
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()
htmx.config.useTemplateFragments = oldUseTemplateFragmentsValue
setTimeout(function(){
window.i.should.equal(1);
delete window.i;
done();
}, 50)
})
});