-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Prevent flush from raising error on detached tag #2447
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
Conversation
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 detectedLatest commit: d49aab2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
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:
|
|
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
It prevents
flush()from raising the following error:TypeError: tag.parentNode is null. Such error happens when thetagthat 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 nullwhen the style tag had been already detached by its parent nodeWhy: 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 nodeChecklist:
Should I add a test?