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.
@@ -463,9 +463,9 @@ const getRelativeXPath = (domNode, docmt, isIndex, isTarget = false, attributesA
463
463
  while (currentNode) {
464
464
  let xpathe = "";
465
465
  let hasUniqueAttr = false;
466
- let attributes = domNode === currentNode ? attributesArray : currentNode.attributes;
466
+ let attributes = domNode === currentNode ? attributesArray ?? currentNode.attributes : currentNode.attributes;
467
467
  // Loop through attributes to check for unique identifiers
468
- for (const attrName of attributes) {
468
+ for (const attrName of Array.from(attributes)) {
469
469
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
470
470
  let attrValue = attrName.nodeValue;
471
471
  // Clean up attribute value
@@ -782,7 +782,7 @@ const getReferenceElementsXpath = (domNode, docmt, isTarget) => {
782
782
  }
783
783
  }
784
784
  if (domNode.attributes) {
785
- for (const attrName of domNode.attributes) {
785
+ for (const attrName of Array.from(domNode.attributes)) {
786
786
  if (checkBlockedAttributes(attrName, domNode, isTarget)) {
787
787
  let attrValue = attrName.nodeValue;
788
788
  if (attrValue) {
@@ -994,7 +994,7 @@ const getUniqueParentXpath = (domNode, docmt, node, isTarget, nodeXpath, isIndex
994
994
  let currentNode = domNode;
995
995
  while (currentNode && currentNode.nodeType === 1) {
996
996
  const hasUniqueAttr = false;
997
- for (const attrName of currentNode.attributes) {
997
+ for (const attrName of Array.from(currentNode.attributes)) {
998
998
  if (checkBlockedAttributes(attrName, currentNode, isTarget)) {
999
999
  let attrValue = attrName.nodeValue;
1000
1000
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1100,7 +1100,7 @@ const getParentRelativeXpath = (domNode, docmt, node, isTarget) => {
1100
1100
  }
1101
1101
  // BASE CASE #2: Check for unique attributes
1102
1102
  let uniqueAttrFound = false;
1103
- for (const attr of currentNode.attributes) {
1103
+ for (const attr of Array.from(currentNode.attributes)) {
1104
1104
  if (checkBlockedAttributes(attr, currentNode, isTarget)) {
1105
1105
  let attrValue = attr.nodeValue;
1106
1106
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1176,7 +1176,7 @@ const getChildRelativeXpath = (domNode, docmt, node) => {
1176
1176
  do {
1177
1177
  let uniqueAttrFound = false;
1178
1178
  for (currentNode = st.pop(); currentNode !== null;) {
1179
- for (const attr of currentNode.attributes) {
1179
+ for (const attr of Array.from(currentNode.attributes)) {
1180
1180
  if (checkBlockedAttributes(attr, currentNode, true)) {
1181
1181
  let attrValue = attr.nodeValue;
1182
1182
  attrValue = attrValue?.replace("removePointers", "") ?? "";
@@ -1258,7 +1258,7 @@ const getSiblingRelativeXPath = (domNode, docmt, isTarget, nodeXpath) => {
1258
1258
  const processSibling = (sibling, domNode, docmt, nodeXpath, axis, isTarget) => {
1259
1259
  try {
1260
1260
  if (sibling.hasAttributes()) {
1261
- for (const attr of sibling.attributes) {
1261
+ for (const attr of Array.from(sibling.attributes)) {
1262
1262
  let xpathe = intermediateXpathStep(sibling, {
1263
1263
  name: attr.name,
1264
1264
  value: attr.value,
@@ -1615,7 +1615,7 @@ const parseDOM = (element, doc, isIndex, isTarget) => {
1615
1615
  const docmt = targetElemt?.ownerDocument || doc;
1616
1616
  const tag = targetElemt.tagName;
1617
1617
  const { attributes } = targetElemt;
1618
- addAllXPathAttributes([...attributes], targetElemt, docmt, isIndex, isTarget);
1618
+ addAllXPathAttributes(Array.from(attributes), targetElemt, docmt, isIndex, isTarget);
1619
1619
  {
1620
1620
  if (xpathData$1.length) {
1621
1621
  const len = xpathData$1.length;
@@ -1634,7 +1634,7 @@ const parseDOM = (element, doc, isIndex, isTarget) => {
1634
1634
  }
1635
1635
  console.log(xpathData$1);
1636
1636
  if (!xpathData$1.length) {
1637
- addRelativeXpaths(targetElemt, docmt, isIndex, isTarget, [...targetElemt.attributes]);
1637
+ addRelativeXpaths(targetElemt, docmt, isIndex, isTarget, Array.from(targetElemt.attributes));
1638
1638
  }
1639
1639
  return xpathData$1;
1640
1640
  };
@@ -1901,8 +1901,8 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
1901
1901
  }
1902
1902
  }
1903
1903
  if (refExpectElement[refExpectElement.length - 2].attributes) {
1904
- for (const attrName of refExpectElement[refExpectElement.length - 2]
1905
- .attributes) {
1904
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
1905
+ .attributes)) {
1906
1906
  if (checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)) {
1907
1907
  let attrValue = attrName.nodeValue;
1908
1908
  if (attrValue) {
@@ -1928,8 +1928,8 @@ const getDescendantXpath = (refExpectElement, docmt, xpaths1, xpaths2, relation,
1928
1928
  }
1929
1929
  }
1930
1930
  }
1931
- for (const attrName of refExpectElement[refExpectElement.length - 2]
1932
- .attributes) {
1931
+ for (const attrName of Array.from(refExpectElement[refExpectElement.length - 2]
1932
+ .attributes)) {
1933
1933
  if (checkBlockedAttributes(attrName, refExpectElement[refExpectElement.length - 2], false)) {
1934
1934
  let attrValue = attrName.nodeValue;
1935
1935
  if (attrValue) {
@@ -2079,7 +2079,7 @@ const getReferenceElementXpath = (element) => {
2079
2079
  xpaths1 = [
2080
2080
  {
2081
2081
  key: "",
2082
- value: getRelativeXPath(element, element.ownerDocument, false, false, [...element.attributes]),
2082
+ value: getRelativeXPath(element, element.ownerDocument, false, false, Array.from(element.attributes)),
2083
2083
  },
2084
2084
  ];
2085
2085
  }
@@ -2087,7 +2087,7 @@ const getReferenceElementXpath = (element) => {
2087
2087
  xpaths1 = [
2088
2088
  {
2089
2089
  key: "",
2090
- value: getRelativeXPath(element, element.ownerDocument, true, false, [...element.attributes]),
2090
+ value: getRelativeXPath(element, element.ownerDocument, true, false, Array.from(element.attributes)),
2091
2091
  },
2092
2092
  ];
2093
2093
  xpaths1 = xpaths1?.map((x) => x.value.charAt(0) == "(" &&