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

Do not reset global.document before CustomElement:disconnectedCallbac… #11871

Merged

Conversation

dalvarezmartinez1
Copy link
Contributor

Summary

The order of the statements inside of the teardown function was changed.
This is due to document not being available in the disconnectedCallback function of CustomElements.

The stack trace looks something like this:
this.global.close(); -> window.js::close -> Element.js::innerHTML -> custom-elements.js::ceReactionsPostSteps -> custom-elements.js::invokeCEReactions -> Function.js::invokeTheCallbackFunction -> my-element::disconnectedCallback

Afaik, the document should be available inside of disconnectedCallback, if it's not this results in a:
"Error: Uncaught [TypeError: Cannot read property 'dispatchEvent' of null]"

Test plan

I ran yarn build and yarn test. Something weird: during the yarn test, it was written 1 test failed but at the end all succeeded.

@codecov-commenter
Copy link

Codecov Report

Merging #11871 (c6d4dd1) into main (d7f0975) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #11871   +/-   ##
=======================================
  Coverage   68.93%   68.93%           
=======================================
  Files         312      312           
  Lines       16412    16412           
  Branches     4760     4760           
=======================================
  Hits        11314    11314           
  Misses       5071     5071           
  Partials       27       27           
Impacted Files Coverage Δ
packages/jest-environment-jsdom/src/index.ts 42.85% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7f0975...c6d4dd1. Read the comment docs.

@SimenB
Copy link
Member

SimenB commented Sep 17, 2021

@dalvarezmartinez1 Thanks for sending a PR! Could you add a test that fails without this change and a changelog entry? 🙂

@SimenB
Copy link
Member

SimenB commented Sep 29, 2021

@dalvarezmartinez1 ping 🙂

@dalvarezmartinez1
Copy link
Contributor Author

It's on my list, I've been crazy busy lately, please don't close it, I will eventually do it

@dalvarezmartinez1 dalvarezmartinez1 force-pushed the do-not-reset-document-prematurely branch 2 times, most recently from 8363f1e to 84962fa Compare November 3, 2021 18:14
…k has finished running, document should be accessible in this callback function
@dalvarezmartinez1
Copy link
Contributor Author

@SimenB added test and changelog entry

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks!

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants