[Bugfix] Fix ie11 incompatible syntax (#1591)

Fix IE11 incompatible syntax
This commit is contained in:
Vincent 2023-07-17 23:04:04 +02:00 committed by GitHub
parent b085d89459
commit dff8f3355f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -391,7 +391,7 @@ return (function () {
function bodyContains(elt) { function bodyContains(elt) {
// IE Fix // IE Fix
if (elt.getRootNode && elt.getRootNode() instanceof ShadowRoot) { if (elt.getRootNode && elt.getRootNode() instanceof window.ShadowRoot) {
return getDocument().body.contains(elt.getRootNode().host); return getDocument().body.contains(elt.getRootNode().host);
} else { } else {
return getDocument().body.contains(elt); return getDocument().body.contains(elt);
@ -965,7 +965,7 @@ return (function () {
newElt = eltBeforeNewContent.nextSibling; newElt = eltBeforeNewContent.nextSibling;
} }
getInternalData(target).replacedWith = newElt; // tuck away so we can fire events on it later getInternalData(target).replacedWith = newElt; // tuck away so we can fire events on it later
settleInfo.elts = settleInfo.elts.filter(e => e != target); settleInfo.elts = settleInfo.elts.filter(function(e) { return e != target });
while(newElt && newElt !== target) { while(newElt && newElt !== target) {
if (newElt.nodeType === Node.ELEMENT_NODE) { if (newElt.nodeType === Node.ELEMENT_NODE) {
settleInfo.elts.push(newElt); settleInfo.elts.push(newElt);
@ -1905,7 +1905,7 @@ return (function () {
return func.call(elt, e); return func.call(elt, e);
}); });
nodeData.onHandlers.push({event:eventName, listener:listener}); nodeData.onHandlers.push({event:eventName, listener:listener});
return {nodeData, code, func, listener}; return {nodeData:nodeData, code:code, func:func, listener:listener};
} }
function processHxOn(elt) { function processHxOn(elt) {
@ -1938,8 +1938,9 @@ return (function () {
// wipe any previous on handlers so that this function takes precedence // wipe any previous on handlers so that this function takes precedence
deInitOnHandlers(elt) deInitOnHandlers(elt)
for (const attr of elt.attributes) { for (var i = 0; i < elt.attributes.length; i++) {
const { name, value } = attr var name = elt.attributes[i].name
var value = elt.attributes[i].value
if (name.startsWith("hx-on:") || name.startsWith("data-hx-on:")) { if (name.startsWith("hx-on:") || name.startsWith("data-hx-on:")) {
let eventName = name.slice(name.indexOf(":") + 1) let eventName = name.slice(name.indexOf(":") + 1)
// if the eventName starts with a colon, prepend "htmx" for shorthand support // if the eventName starts with a colon, prepend "htmx" for shorthand support