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

Handle null parentElement for selection anchor #18884

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

hubgit
Copy link
Contributor

@hubgit hubgit commented Oct 11, 2024

In the selectionchange handler that's added to the document by TextLayerBuilder, there is a line which accesses anchor.parentElement.closest(".textLayer").

This throws an error if anchor.parentElement is null, which can happen if the selection is inside a shadow root - I can reproduce it by selecting text inside Grammarly's popover on a page where PDF.is is being used.

grammarly-error

grammarly-element

The error is only seen in non-Firefox browsers, as there is a line which returns earlier in Firefox.

This change handles the null parentElement gracefully, to avoid throwing the error.

@timvandermeij
Copy link
Contributor

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.241.84.105:8877/a1ada5b8ae11d90/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/a1ada5b8ae11d90/output.txt

Total script time: 1.01 mins

Published

@timvandermeij
Copy link
Contributor

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 0

Live output at: http://54.241.84.105:8877/297883ec4e536b7/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 0

Live output at: http://54.193.163.58:8877/22a3fb8e708c06e/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/297883ec4e536b7/output.txt

Total script time: 9.21 mins

  • Integration Tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/22a3fb8e708c06e/output.txt

Total script time: 20.43 mins

  • Integration Tests: Passed

@timvandermeij timvandermeij merged commit 96bced7 into mozilla:master Oct 15, 2024
6 checks passed
@timvandermeij
Copy link
Contributor

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants