mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 15:25:26 +00:00
use title node innerHTML if possible so that HTML escape sequences are respected.
This commit is contained in:
parent
81c78109a3
commit
13366ac089
11
src/htmx.js
11
src/htmx.js
@ -267,7 +267,7 @@ return (function () {
|
|||||||
if (selector) {
|
if (selector) {
|
||||||
return eltOrSelector.querySelector(selector);
|
return eltOrSelector.querySelector(selector);
|
||||||
} else {
|
} else {
|
||||||
return getDocument().body.querySelector(eltOrSelector);
|
return find(getDocument(), eltOrSelector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ return (function () {
|
|||||||
if (selector) {
|
if (selector) {
|
||||||
return eltOrSelector.querySelectorAll(selector);
|
return eltOrSelector.querySelectorAll(selector);
|
||||||
} else {
|
} else {
|
||||||
return getDocument().body.querySelectorAll(eltOrSelector);
|
return findAll(getDocument(), eltOrSelector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +623,12 @@ return (function () {
|
|||||||
function selectAndSwap(swapStyle, target, elt, responseText, settleInfo) {
|
function selectAndSwap(swapStyle, target, elt, responseText, settleInfo) {
|
||||||
var title = findTitle(responseText);
|
var title = findTitle(responseText);
|
||||||
if(title) {
|
if(title) {
|
||||||
window.document.title = title;
|
var titleElt = find("title");
|
||||||
|
if(titleElt) {
|
||||||
|
titleElt.innerHTML = title;
|
||||||
|
} else {
|
||||||
|
window.document.title = title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var fragment = makeFragment(responseText);
|
var fragment = makeFragment(responseText);
|
||||||
if (fragment) {
|
if (fragment) {
|
||||||
|
@ -773,5 +773,17 @@ describe("Core htmx AJAX Tests", function(){
|
|||||||
window.document.title.should.equal("htmx rocks!");
|
window.document.title.should.equal("htmx rocks!");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('title update does not URL escapte', function()
|
||||||
|
{
|
||||||
|
this.server.respondWith("GET", "/test", function (xhr) {
|
||||||
|
xhr.respond(200, {}, "<title></> htmx rocks!</title>Clicked!");
|
||||||
|
});
|
||||||
|
var btn = make('<button hx-get="/test">Click Me!</button>')
|
||||||
|
btn.click();
|
||||||
|
this.server.respond();
|
||||||
|
btn.innerText.should.equal("Clicked!");
|
||||||
|
window.document.title.should.equal("</> htmx rocks!");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user