fix dom parsing issue (#1365)

This commit is contained in:
LawyZheng
2024-12-11 00:05:16 +08:00
committed by GitHub
parent 761a21eaaf
commit 583075899f

View File

@@ -787,6 +787,10 @@ const isReactSelectDropdown = (element) => {
}; };
function hasNgAttribute(element) { function hasNgAttribute(element) {
if (!element.attributes[Symbol.iterator]) {
return false;
}
for (let attr of element.attributes) { for (let attr of element.attributes) {
if (attr.name.startsWith("ng-")) { if (attr.name.startsWith("ng-")) {
return true; return true;
@@ -1057,27 +1061,33 @@ function buildElementObject(frame, element, interactable, purgeable = false) {
element.setAttribute("unique_id", element_id); element.setAttribute("unique_id", element_id);
const attrs = {}; const attrs = {};
for (const attr of element.attributes) { if (element.attributes[Symbol.iterator]) {
var attrValue = attr.value; for (const attr of element.attributes) {
if ( var attrValue = attr.value;
attr.name === "required" || if (
attr.name === "aria-required" || attr.name === "required" ||
attr.name === "checked" || attr.name === "aria-required" ||
attr.name === "aria-checked" || attr.name === "checked" ||
attr.name === "selected" || attr.name === "aria-checked" ||
attr.name === "aria-selected" || attr.name === "selected" ||
attr.name === "readonly" || attr.name === "aria-selected" ||
attr.name === "aria-readonly" || attr.name === "readonly" ||
attr.name === "disabled" || attr.name === "aria-readonly" ||
attr.name === "aria-disabled" attr.name === "disabled" ||
) { attr.name === "aria-disabled"
if (attrValue && attrValue.toLowerCase() === "false") { ) {
attrValue = false; if (attrValue && attrValue.toLowerCase() === "false") {
} else { attrValue = false;
attrValue = true; } else {
attrValue = true;
}
} }
attrs[attr.name] = attrValue;
} }
attrs[attr.name] = attrValue; } else {
console.warn(
"element.attributes is not iterable. element_id=" + element_id,
);
} }
if ( if (