Skip to content

Conversation

@ylc395
Copy link
Contributor

@ylc395 ylc395 commented Apr 25, 2025

add a root element param for processFragmentDirectives

@google-cla
Copy link

google-cla bot commented Apr 25, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ylc395 ylc395 force-pushed the feature/add-search-root-element branch from fdbd7ea to 295d102 Compare April 25, 2025 10:42
@tomayac
Copy link
Member

tomayac commented Apr 25, 2025

Thanks for the PR! This library is meant to polyfill URL Fragment Text Directives, and the algorithm for finding such text directives assumes to always search the entire document. I don't think specifying a different root makes sense given this context, but I might be missing the motivation for the PR.

@ylc395
Copy link
Contributor Author

ylc395 commented Apr 25, 2025

@tomayac I'm making an web app, which can process text fragment directives for a contained HTML document. Specifying the root element of the contained HTML would be helpful.

@tomayac
Copy link
Member

tomayac commented Apr 25, 2025

To be compliant, the text fragment would need to be searched in the entire document. Is it that for your particular use case you can safely assume that the text fragment can only appear in a given part of the document?

@ylc395
Copy link
Contributor Author

ylc395 commented Apr 25, 2025

@tomayac Yes, let's assume that there is a web app for processing other HTML documents, and these HTML documents are treated independently. So we don't want to search text fragment in the main app (the main HTML document)

Copy link
Member

@tomayac tomayac left a comment

Choose a reason for hiding this comment

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

Just two suggestions, but after that LGTM

* process.
* @param {Document} documentToProcess - document where to extract and mark
* fragments in.
* @param {Element} root - the root element where to extract and mark
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {Element} root - the root element where to extract and mark
* @param {Element=} root - the root element where to extract and mark

Copy link
Member

Choose a reason for hiding this comment

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

To mark the parameter as optional.

* @param {TextFragment} textFragment - Text Fragment to highlight.
* @param {Document} documentToProcess - document where to extract and mark
* fragments in.
* @param {Element} root - the root element where to extract and mark
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {Element} root - the root element where to extract and mark
* @param {Element=} root - the root element where to extract and mark

To mark the param as optional.

@ylc395
Copy link
Contributor Author

ylc395 commented Apr 25, 2025

No problem

@ylc395 ylc395 requested a review from tomayac April 25, 2025 11:56
Copy link
Member

@tomayac tomayac left a comment

Choose a reason for hiding this comment

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

LGTM

@tomayac tomayac merged commit 24e9d5a into GoogleChromeLabs:main Apr 25, 2025
1 check passed
@tomayac
Copy link
Member

tomayac commented Apr 25, 2025

Released as v6.4.0. Thanks again!

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.

2 participants