summaryrefslogtreecommitdiffstatshomepage
path: root/src/htmx.js
diff options
context:
space:
mode:
authorcadrgtsecond <148259494+cadrgtsecond@users.noreply.github.com>2024-10-03 01:19:40 +0000
committerGitHub <noreply@github.com>2024-10-02 19:19:40 -0600
commit30ab5c12b1cbdf51bb4c3f36b1ffbf663da9f4a0 (patch)
tree6f7d45be0f23696ab33483387ae9cb9e0813f0c0 /src/htmx.js
parent7dd6cd722437ab1f07b1328602ec2e301a6a0290 (diff)
downloadhtmx-v1.tar.gz
htmx-v1.zip
Allow non-id selectors in `hx-select-oob` to fix #2561 (#2585)v1
* Allow non-id selectors in `hx-select-oob` to fix #2561 * Switch const to var * Fix test case for hx-select-oob
Diffstat (limited to 'src/htmx.js')
-rw-r--r--src/htmx.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/htmx.js b/src/htmx.js
index 597c9b3b..d5d6b036 100644
--- a/src/htmx.js
+++ b/src/htmx.js
@@ -864,13 +864,12 @@ return (function () {
if (oobSelects) {
var oobSelectValues = oobSelects.split(",");
for (var i = 0; i < oobSelectValues.length; i++) {
- var oobSelectValue = oobSelectValues[i].split(":", 2);
- var id = oobSelectValue[0].trim();
- if (id.indexOf("#") === 0) {
- id = id.substring(1);
- }
- var oobValue = oobSelectValue[1] || "true";
- var oobElement = fragment.querySelector("#" + id);
+ var oobSelectValue = oobSelectValues[i]
+ // Support colon in css selectors
+ var colon = oobSelectValue.lastIndexOf(':')
+ var split_at = colon == -1 ? oobSelectValue.length : colon
+ var oobValue = oobSelectValue.substring(split_at + 1) || 'true'
+ var oobElement = fragment.querySelector(oobSelectValue.substring(0, split_at))
if (oobElement) {
oobSwap(oobValue, oobElement, settleInfo);
}