fix: missing braces error
This commit is contained in:
@@ -483,31 +483,31 @@ export const BrowserWindow = () => {
|
|||||||
validatedChildSelectors.forEach((selector, index) => {
|
validatedChildSelectors.forEach((selector, index) => {
|
||||||
try {
|
try {
|
||||||
const listElements = evaluateXPathAllWithShadowSupport(
|
const listElements = evaluateXPathAllWithShadowSupport(
|
||||||
iframeElement.contentDocument!,
|
|
||||||
listSelector,
|
|
||||||
listSelector.includes(">>") || listSelector.startsWith("//")
|
|
||||||
);
|
|
||||||
|
|
||||||
if (listElements.length === 0) return;
|
|
||||||
|
|
||||||
const hasNumericPredicate = /\[\d+\](?![^\[]*@)/.test(selector);
|
|
||||||
|
|
||||||
if (hasNumericPredicate && listElements.length >= 3) {
|
|
||||||
const allMatches = evaluateXPathAllWithShadowSupport(
|
|
||||||
iframeElement.contentDocument!,
|
iframeElement.contentDocument!,
|
||||||
selector,
|
listSelector,
|
||||||
selector.includes(">>") || selector.startsWith("//")
|
listSelector.includes(">>") || listSelector.startsWith("//")
|
||||||
);
|
);
|
||||||
|
|
||||||
const matchRatio = allMatches.length / listElements.length;
|
if (listElements.length === 0) return;
|
||||||
|
|
||||||
if (matchRatio < 0.6) {
|
const hasNumericPredicate = /\[\d+\](?![^\[]*@)/.test(selector);
|
||||||
return;
|
|
||||||
|
if (hasNumericPredicate && listElements.length >= 3) {
|
||||||
|
const allMatches = evaluateXPathAllWithShadowSupport(
|
||||||
|
iframeElement.contentDocument!,
|
||||||
|
selector,
|
||||||
|
selector.includes(">>") || selector.startsWith("//")
|
||||||
|
);
|
||||||
|
|
||||||
|
const matchRatio = allMatches.length / listElements.length;
|
||||||
|
|
||||||
|
if (matchRatio < 0.6) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const firstListElement = listElements[0];
|
const firstListElement = listElements[0];
|
||||||
|
|
||||||
const elements = evaluateXPathAllWithShadowSupport(
|
const elements = evaluateXPathAllWithShadowSupport(
|
||||||
iframeElement.contentDocument!,
|
iframeElement.contentDocument!,
|
||||||
selector,
|
selector,
|
||||||
@@ -629,32 +629,32 @@ export const BrowserWindow = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldId = Date.now() + index * 1000 + 500;
|
const fieldId = Date.now() + index * 1000 + 500;
|
||||||
candidateFields.push({
|
candidateFields.push({
|
||||||
id: fieldId,
|
id: fieldId,
|
||||||
element: anchorParent as HTMLElement,
|
element: anchorParent as HTMLElement,
|
||||||
isLeaf: true,
|
isLeaf: true,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
position: position,
|
position: position,
|
||||||
field: {
|
field: {
|
||||||
id: fieldId,
|
id: fieldId,
|
||||||
type: "text",
|
type: "text",
|
||||||
label: `Label ${index + 1} Link`,
|
label: `Label ${index + 1} Link`,
|
||||||
data: href,
|
data: href,
|
||||||
selectorObj: {
|
selectorObj: {
|
||||||
selector: anchorSelector,
|
selector: anchorSelector,
|
||||||
attribute: 'href',
|
attribute: 'href',
|
||||||
tag: 'A',
|
tag: 'A',
|
||||||
isShadow: anchorParent.getRootNode() instanceof ShadowRoot,
|
isShadow: anchorParent.getRootNode() instanceof ShadowRoot,
|
||||||
fallbackSelector: generateFallbackSelector(anchorParent as HTMLElement)
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
} catch (error) {
|
|
||||||
console.warn(`Failed to process child selector ${selector}:`, error);
|
console.warn(`Failed to process child selector ${selector}:`, error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user