Skip to content

Commit

Permalink
Make it work with hidden=until-found nodes
Browse files Browse the repository at this point in the history
Fixes #167
  • Loading branch information
tomayac authored Jan 31, 2025
1 parent def94c5 commit a9305a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "text-fragments-polyfill",
"version": "6.1.0",
"version": "6.2.0",
"description": "This is a polyfill for the [Text Fragments](https://wicg.github.io/scroll-to-text-fragment/) feature for browsers that don't support it natively.",
"main": "./dist/text-fragments.js",
"browser": "./dist/text-fragments.js",
Expand Down
3 changes: 3 additions & 0 deletions src/text-fragment-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ const isNodeVisible =
let elt = node;
while (elt != null && !(elt instanceof HTMLElement)) elt = elt.parentNode;
if (elt != null) {
if (elt.hidden === 'until-found') {
return true;
}
const nodeStyle = window.getComputedStyle(elt);
// If the node is not rendered, just skip it.
if (nodeStyle.visibility === 'hidden' || nodeStyle.display === 'none' ||
Expand Down

0 comments on commit a9305a1

Please sign in to comment.