Merge pull request #783 from RohitR311/better-selgen
fix: ensure consistent element selection by applying parent-child grouping
This commit is contained in:
@@ -957,19 +957,10 @@ class ClientSelectorGenerator {
|
||||
);
|
||||
|
||||
if (groupedElementsAtPoint.length > 0) {
|
||||
const hasAnchorTag = groupedElementsAtPoint.some(
|
||||
(el) => el.tagName === "A"
|
||||
let filteredElements = this.filterParentChildGroupedElements(
|
||||
groupedElementsAtPoint
|
||||
);
|
||||
|
||||
let filteredElements = groupedElementsAtPoint;
|
||||
|
||||
if (hasAnchorTag) {
|
||||
// Apply parent-child filtering when anchor tags are present
|
||||
filteredElements = this.filterParentChildGroupedElements(
|
||||
groupedElementsAtPoint
|
||||
);
|
||||
}
|
||||
|
||||
// Sort by DOM depth (deeper elements first for more specificity)
|
||||
filteredElements.sort((a, b) => {
|
||||
const aDepth = this.getElementDepth(a);
|
||||
|
||||
Reference in New Issue
Block a user