Skip to content

Commit

Permalink
[Bugfix] Fix references to element.id (#1563)
Browse files Browse the repository at this point in the history
Fix references to element.id
  • Loading branch information
Telroshan authored Jul 22, 2023
1 parent 91d0630 commit a29403f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a29403f

Please sign in to comment.