Merge pull request #145 from rros/users/rros/fix-queryselector-issue

Fix issue with unquoted id attribute in query selector
This commit is contained in:
1cg 2020-08-30 18:50:50 -07:00 committed by GitHub
commit 8983448b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -436,7 +436,7 @@ return (function () {
function handleAttributes(parentNode, fragment, settleInfo) {
forEach(fragment.querySelectorAll("[id]"), function (newNode) {
if (newNode.id && newNode.id.length > 0) {
var oldNode = parentNode.querySelector(newNode.tagName + "[id=" + newNode.id + "]");
var oldNode = parentNode.querySelector(newNode.tagName + "[id='" + newNode.id + "']");
if (oldNode && oldNode !== parentNode) {
var newAttributes = newNode.cloneNode();
cloneAttributes(newNode, oldNode);

View File

@ -65,4 +65,12 @@ describe("Core htmx Regression Tests", function(){
div.innerText.should.contain("Foo")
});
it ('id with dot in value doesnt cause an error', function(){
this.server.respondWith("GET", "/test", "Foo <div id='ViewModel.Test'></div>");
var div = make('<div hx-get="/test">Get It</div>');
div.click();
this.server.respond();
div.innerText.should.contain("Foo");
});
})