handle html parsing when script tag starts content

fixes https://github.com/bigskysoftware/htmx/issues/228
This commit is contained in:
carson 2020-11-11 10:04:01 -07:00
parent 71a9b48dd4
commit e0b5b52979
2 changed files with 19 additions and 0 deletions

View File

@ -161,6 +161,8 @@ return (function () {
case "td":
case "th":
return parseHTML("<table><tbody><tr>" + resp + "</tr></tbody></table>", 3);
case "script":
return parseHTML("<div>" + resp + "</div>", 1);
default:
return parseHTML(resp, 0);
}

View File

@ -546,6 +546,23 @@ describe("Core htmx AJAX Tests", function(){
}
});
it('stand alone script nodes evaluate', function()
{
var globalWasCalled = false;
window.callGlobal = function() {
globalWasCalled = true;
}
try {
this.server.respondWith("GET", "/test", "<script type='text/javascript'>callGlobal()</script>");
var div = make("<div hx-get='/test'></div>");
div.click();
this.server.respond();
globalWasCalled.should.equal(true);
} finally {
delete window.callGlobal;
}
});
it('child script nodes evaluate when children', function()
{
var globalWasCalled = false;