Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag interfering with Xpath fix #14

Merged
merged 14 commits into from
Nov 27, 2023
Merged

Tag interfering with Xpath fix #14

merged 14 commits into from
Nov 27, 2023

Conversation

KhoomeiK
Copy link
Collaborator

Inserting the tag while calculating the xpaths for elements was resulting in the tarsier tags interfering with xpath indexing for spans. I separated tag insertion out to a separate loop that runs after xpaths are calculated.

const elTagName = el.tagName.toLowerCase();
const idStr = inputTags.includes(elTagName) ? `{${idNum}}` : `[${idNum}]`;
// const idStr = inputTags.includes(elTagName) ? `{${idNum}}` : `[${idNum}]`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we jus delete the commented code?

@@ -162,36 +162,69 @@ window.tagifyWebpage = (tagLeafTexts = false) => {
continue;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions a bit long and hard to read. Ideally we broke this apart but given this is a js utility file in a python project this should be fine.

idToXpath[idNum] = getElementXPath(el);

// create the span for the id tag
// let idSpan = create_tagged_span(idStr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove all commented out code

const interactable = isInteractable(el);
const elTagName = el.tagName.toLowerCase();
const idStr = inputTags.includes(elTagName) ? `{${idNum}}` : `[${idNum}]`;

// create the span for the id tag
let idSpan = create_tagged_span(idStr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a const

} else if (elTagName === "select") {
// leave select blank - we'll give a tag ID to the options
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be simplified? This can be combined with the statement above

@awtkns awtkns merged commit 9c8e352 into main Nov 27, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants