Revert changes to www/*

This commit is contained in:
Deniz Akşimşek 2021-01-15 15:16:07 +00:00
parent c36b18b189
commit 223f4c9e53
3 changed files with 12 additions and 120 deletions

View File

@ -331,32 +331,6 @@ return (function () {
while (elt = elt && parentElt(elt));
}
// Like querySelectorAll, but supports [closest] and [find]
// and other features that might have been added w/o updating this comment
// returns Array | NodeList
function querySelectorAllWithFeatures(eltOrSelector, selector) {
var elt;
if (selector === undefined) {
selector = eltOrSelector;
elt = getDocument();
} else {
elt = eltOrSelector;
}
if (selector.indexOf("closest ") === 0) {
return [closest(elt, selector.substr(8))];
} else if (selector.indexOf("find ") === 0) {
return [find(elt, selector.substr(5))];
} else {
return getDocument().querySelectorAll(selector);
}
}
// See querySelectorAllWithFeatures
function querySelectorWithFeatures(eltOrSelector, selector) {
return querySelectorAllWithFeatures(eltOrSelector, selector)[0]
}
function resolveTarget(arg2) {
if (isType(arg2, 'String')) {
return find(arg2);
@ -409,8 +383,12 @@ return (function () {
var targetStr = getAttributeValue(explicitTarget, "hx-target");
if (targetStr === "this") {
return explicitTarget;
} else if (targetStr.indexOf("closest ") === 0) {
return closest(elt, targetStr.substr(8));
} else if (targetStr.indexOf("find ") === 0) {
return find(elt, targetStr.substr(5));
} else {
return querySelectorWithFeatures(elt, targetStr)
return getDocument().querySelector(targetStr);
}
} else {
var data = getInternalData(elt);
@ -1615,18 +1593,6 @@ return (function () {
}
}
function descendantsToInclude(elt) {
var rv = [];
var descendants = elt.querySelectorAll('*')
forEach(descendants, function (descendant) {
if (shouldInclude(descendant)) {
rv.push(descendant);
}
})
return rv;
}
function getInputValues(elt, verb) {
var processed = [];
var values = {
@ -1650,15 +1616,9 @@ return (function () {
// include any explicit includes
var includes = getClosestAttributeValue(elt, "hx-include");
if (includes) {
var nodes = querySelectorAllWithFeatures(elt, includes);
var nodes = getDocument().querySelectorAll(includes);
forEach(nodes, function(node) {
processInputValue(processed, values.includes, errors, node, validate);
if (!shouldInclude(node)) {
var descendants = descendantsToInclude(node);
forEach(descendants, function (descendant) {
processInputValue(processed, values.includes, errors, descendant, validate);
})
}
});
}

View File

@ -331,32 +331,6 @@ return (function () {
while (elt = elt && parentElt(elt));
}
// Like querySelectorAll, but supports [closest] and [find]
// and other features that might have been added w/o updating this comment
// returns Array | NodeList
function querySelectorAllWithFeatures(eltOrSelector, selector) {
var elt;
if (selector === undefined) {
selector = eltOrSelector;
elt = getDocument();
} else {
elt = eltOrSelector;
}
if (selector.indexOf("closest ") === 0) {
return [closest(elt, selector.substr(8))];
} else if (selector.indexOf("find ") === 0) {
return [find(elt, selector.substr(5))];
} else {
return getDocument().querySelectorAll(selector);
}
}
// See querySelectorAllWithFeatures
function querySelectorWithFeatures(eltOrSelector, selector) {
return querySelectorAllWithFeatures(eltOrSelector, selector)[0]
}
function resolveTarget(arg2) {
if (isType(arg2, 'String')) {
return find(arg2);
@ -409,8 +383,12 @@ return (function () {
var targetStr = getAttributeValue(explicitTarget, "hx-target");
if (targetStr === "this") {
return explicitTarget;
} else if (targetStr.indexOf("closest ") === 0) {
return closest(elt, targetStr.substr(8));
} else if (targetStr.indexOf("find ") === 0) {
return find(elt, targetStr.substr(5));
} else {
return querySelectorWithFeatures(elt, targetStr)
return getDocument().querySelector(targetStr);
}
} else {
var data = getInternalData(elt);
@ -1615,18 +1593,6 @@ return (function () {
}
}
function descendantsToInclude(elt) {
var rv = [];
var descendants = elt.querySelectorAll('*')
forEach(descendants, function (descendant) {
if (shouldInclude(descendant)) {
rv.push(descendant);
}
})
return rv;
}
function getInputValues(elt, verb) {
var processed = [];
var values = {
@ -1650,15 +1616,9 @@ return (function () {
// include any explicit includes
var includes = getClosestAttributeValue(elt, "hx-include");
if (includes) {
var nodes = querySelectorAllWithFeatures(elt, includes);
var nodes = getDocument().querySelectorAll(includes);
forEach(nodes, function(node) {
processInputValue(processed, values.includes, errors, node, validate);
if (!shouldInclude(node)) {
var descendants = descendantsToInclude(node);
forEach(descendants, function (descendant) {
processInputValue(processed, values.includes, errors, descendant, validate);
})
}
});
}

View File

@ -165,33 +165,5 @@ describe("hx-include attribute", function() {
div.innerHTML.should.equal("Clicked!");
});
it('If the element is not includeable, its descendant inputs are included', function () {
this.server.respondWith("POST", "/include", function (xhr) {
var params = getParameters(xhr);
params['i1'].should.equal("test");
params['i2'].should.equal("test");
xhr.respond(200, {}, "Clicked!")
});
make('<div id="i"><input name="i1" value="test"/><input name="i2" value="test"/></div>');
var div = make('<div hx-post="/include" hx-include="#i"></div>')
div.click();
this.server.respond();
div.innerHTML.should.equal("Clicked!");
})
it('The `closest` modifier can be used in the hx-include selector', function () {
this.server.respondWith("POST", "/include", function (xhr) {
var params = getParameters(xhr);
params['i1'].should.equal("test");
params['i2'].should.equal("test");
xhr.respond(200, {}, "Clicked!")
});
make('<div id="i"><input name="i1" value="test"/><input name="i2" value="test"/>'+
'<button id="btn" hx-post="/include" hx-include="closest div"></button></div>');
var btn = byId('btn')
btn.click();
this.server.respond();
btn.innerHTML.should.equal("Clicked!");
})
});