From a29403f4b7979d78f3dc5450684d2c28bdbb3c17 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 22 Jul 2023 16:37:42 +0200 Subject: [PATCH] [Bugfix] Fix references to element.id (#1563) Fix references to element.id --- src/htmx.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/htmx.js b/src/htmx.js index fdf6688d..5f87cb82 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -760,7 +760,7 @@ return (function () { * @returns */ function oobSwap(oobValue, oobElement, settleInfo) { - var selector = "#" + oobElement.id; + var selector = "#" + getRawAttribute(oobElement, "id"); var swapStyle = "outerHTML"; if (oobValue === "true") { // do nothing @@ -841,8 +841,9 @@ return (function () { function handleAttributes(parentNode, fragment, settleInfo) { forEach(fragment.querySelectorAll("[id]"), function (newNode) { - if (newNode.id && newNode.id.length > 0) { - var normalizedId = newNode.id.replace("'", "\\'"); + var id = getRawAttribute(newNode, "id") + if (id && id.length > 0) { + var normalizedId = id.replace("'", "\\'"); var normalizedTag = newNode.tagName.replace(':', '\\:'); var oldNode = parentNode.querySelector(normalizedTag + "[id='" + normalizedId + "']"); if (oldNode && oldNode !== parentNode) { @@ -3354,8 +3355,8 @@ return (function () { if (selectionInfo.elt && !bodyContains(selectionInfo.elt) && - selectionInfo.elt.id) { - var newActiveElt = document.getElementById(selectionInfo.elt.id); + getRawAttribute(selectionInfo.elt, "id")) { + var newActiveElt = document.getElementById(getRawAttribute(selectionInfo.elt, "id")); var focusOptions = { preventScroll: swapSpec.focusScroll !== undefined ? !swapSpec.focusScroll : !htmx.config.defaultFocusScroll }; if (newActiveElt) { // @ts-ignore