[Bugfix] Fix references to element.id (#1563)

Fix references to element.id
This commit is contained in:
Vincent 2023-07-22 16:37:42 +02:00 committed by GitHub
parent 91d06309dc
commit a29403f4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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