ff-dom 1.0.18-beta.1 → 1.0.18-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -459,9 +459,9 @@ const getRelativeXPath = (domNode, docmt, isIndex, isTarget = false, attributesA
459
459
  while (currentNode) {
460
460
  let xpathe = "";
461
461
  let hasUniqueAttr = false;
462
- let attributes = domNode === currentNode ? attributesArray : currentNode.attributes;
462
+ let attributes = domNode === currentNode ? attributesArray ?? currentNode.attributes : currentNode.attributes;
463
463
  // Loop through attributes to check for unique identifiers
464
- for (const attrName of attributes) {
464
+ for (const attrName of Array.from(attributes)) {
465
465
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
466
466
  let attrValue = attrName.nodeValue;
467
467
  // Clean up attribute value
@@ -778,7 +778,7 @@ const getReferenceElementsXpath = (domNode, docmt, isTarget) => {
778
778
  }
779
779
  }
780
780
  if (domNode.attributes) {
781
- for (const attrName of domNode.attributes) {
781
+ for (const attrName of Array.from(domNode.attributes)) {
782
782
  if (checkBlockedAttributes(attrName, domNode, isTarget)) {
783
783
  let attrValue = attrName.nodeValue;
784
784
  if (attrValue) {
@@ -990,7 +990,7 @@ const getUniqueParentXpath = (domNode, docmt, node, isTarget, nodeXpath, isIndex
990
990
  let currentNode = domNode;
991
991
  while (currentNode && currentNode.nodeType === 1) {
992
992
  const hasUniqueAttr = false;
993
- for (const attrName of currentNode.attributes) {
993
+ for (const attrName of Array.from(currentNode.attributes)) {
994
994
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
995
995
  let attrValue = attrName.nodeValue;
996
996
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1096,7 +1096,7 @@ const getParentRelativeXpath = (domNode, docmt, node, isTarget) => {
1096
1096
  }
1097
1097
  // BASE CASE #2: Check for unique attributes
1098
1098
  let uniqueAttrFound = false;
1099
- for (const attr of currentNode.attributes) {
1099
+ for (const attr of Array.from(currentNode.attributes)) {
1100
1100
  if (checkBlockedAttributes(attr, currentNode, isTarget)) {
1101
1101
  let attrValue = attr.nodeValue;
1102
1102
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1172,7 +1172,7 @@ const getChildRelativeXpath = (domNode, docmt, node) => {
1172
1172
  do {
1173
1173
  let uniqueAttrFound = false;
1174
1174
  for (currentNode = st.pop(); currentNode !== null;) {
1175
- for (const attr of currentNode.attributes) {
1175
+ for (const attr of Array.from(currentNode.attributes)) {
1176
1176
  if (checkBlockedAttributes(attr, currentNode, true)) {
1177
1177
  let attrValue = attr.nodeValue;
1178
1178
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1254,7 +1254,7 @@ const getSiblingRelativeXPath = (domNode, docmt, isTarget, nodeXpath) => {
1254
1254
  const processSibling = (sibling, domNode, docmt, nodeXpath, axis, isTarget) => {
1255
1255
  try {
1256
1256
  if (sibling.hasAttributes()) {
1257
- for (const attr of sibling.attributes) {
1257
+ for (const attr of Array.from(sibling.attributes)) {
1258
1258
  let xpathe = intermediateXpathStep(sibling, {
1259
1259
  name: attr.name,
1260
1260
  value: attr.value,
@@ -1611,7 +1611,7 @@ const parseDOM = (element, doc, isIndex, isTarget) => {
1611
1611
  const docmt = targetElemt?.ownerDocument || doc;
1612
1612
  const tag = targetElemt.tagName;
1613
1613
  const { attributes } = targetElemt;
1614
- addAllXPathAttributes([...attributes], targetElemt, docmt, isIndex, isTarget);
1614
+ addAllXPathAttributes(Array.from(attributes), targetElemt, docmt, isIndex, isTarget);
1615
1615
  {
1616
1616
  if (xpathData$1.length) {
1617
1617
  const len = xpathData$1.length;
@@ -1630,7 +1630,7 @@ const parseDOM = (element, doc, isIndex, isTarget) => {
1630
1630
  }
1631
1631
  console.log(xpathData$1);
1632
1632
  if (!xpathData$1.length) {
1633
- addRelativeXpaths(targetElemt, docmt, isIndex, isTarget, [...targetElemt.attributes]);
1633
+ addRelativeXpaths(targetElemt, docmt, isIndex, isTarget, Array.from(targetElemt.attributes));
1634
1634
  }
1635
1635
  return xpathData$1;
1636
1636
  };
@@ -1897,8 +1897,8 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
1897
1897
  }
1898
1898
  }
1899
1899
  if (refExpectElement[refExpectElement.length - 2].attributes) {
1900
- for (const attrName of refExpectElement[refExpectElement.length - 2]
1901
- .attributes) {
1900
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
1901
+ .attributes)) {
1902
1902
  if (checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)) {
1903
1903
  let attrValue = attrName.nodeValue;
1904
1904
  if (attrValue) {
@@ -1924,8 +1924,8 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
1924
1924
  }
1925
1925
  }
1926
1926
  }
1927
- for (const attrName of refExpectElement[refExpectElement.length - 2]
1928
- .attributes) {
1927
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
1928
+ .attributes)) {
1929
1929
  if (checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)) {
1930
1930
  let attrValue = attrName.nodeValue;
1931
1931
  if (attrValue) {
@@ -2075,7 +2075,7 @@ const getReferenceElementXpath = (element) => {
2075
2075
  xpaths1 = [
2076
2076
  {
2077
2077
  key: "",
2078
- value: getRelativeXPath(element, element.ownerDocument, false, false, [...element.attributes]),
2078
+ value: getRelativeXPath(element, element.ownerDocument, false, false, Array.from(element.attributes)),
2079
2079
  },
2080
2080
  ];
2081
2081
  }
@@ -2083,7 +2083,7 @@ const getReferenceElementXpath = (element) => {
2083
2083
  xpaths1 = [
2084
2084
  {
2085
2085
  key: "",
2086
- value: getRelativeXPath(element, element.ownerDocument, true, false, [...element.attributes]),
2086
+ value: getRelativeXPath(element, element.ownerDocument, true, false, Array.from(element.attributes)),
2087
2087
  },
2088
2088
  ];
2089
2089
  xpaths1 = xpaths1?.map((x) => x.value.charAt(0) == "(" &&