Skip to content

Conversation

@mdesantis
Copy link
Contributor

@mdesantis mdesantis commented Aug 3, 2021

It prevents flush() from raising the following error: TypeError: tag.parentNode is null. Such error happens when the tag that is being flushed had already been detached from its parent node by third party code, which may be application code or a library that handles the page routing—I'm experiencing this issue with Turbolinks.

What: it prevents flush() from raising the following error: TypeError: tag.parentNode is null when the style tag had been already detached by its parent node

Why: because it makes play better with third party code that manipulate the style tags somehow

How: it skips the .removeChild(tag) call on the tag's parent node when there is no parent node

Checklist:

  • Documentation N/A
  • Tests
  • Code complete
  • Changeset N/A

Should I add a test?

It prevents `flush()` from raising the following error: `TypeError: tag.parentNode is null`. Such error happens when the `tag` that is being flushed had already been detached from its parent node by a third paryy library, which may be application code or a library that handles the page routing—I'm experiencing this issue with [Turbolinks](https://github.com/turbolinks/turbolinks).
@changeset-bot
Copy link

changeset-bot bot commented Aug 3, 2021

🦋 Changeset detected

Latest commit: d49aab2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@emotion/sheet Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 3, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d49aab2:

Sandbox Source
Emotion Configuration

@Andarist
Copy link
Member

Andarist commented Aug 8, 2021

Thank you for the PR - this has been raised in the past. I would like to dig up the old conversations and evaluate this in the upcoming week, thanks for being patient!

flush() {
// $FlowFixMe
this.tags.forEach(tag => tag.parentNode.removeChild(tag))
this.tags.forEach(tag => tag.parentNode && tag.parentNode.removeChild(tag))
Copy link
Member

Choose a reason for hiding this comment

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

@mitchellhamilton do you have any extra concerns about making this change? After considering this multiple times I think I'm inclined to allow for this.

Copy link
Member

Choose a reason for hiding this comment

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

This seems fine to me

@Andarist Andarist merged commit f2eda82 into emotion-js:main Oct 17, 2021
@Andarist Andarist mentioned this pull request Oct 17, 2021
4 tasks
@github-actions github-actions bot mentioned this pull request Oct 17, 2021
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.

3 participants