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

Don't reset <head> when using injectHTML #631

Merged
merged 1 commit into from
Dec 19, 2022
Merged

Conversation

calebeby
Copy link
Member

@calebeby calebeby commented Dec 19, 2022

I noticed this bug while trying to update @cloudfour/patterns. This is a bug introduced in 3.0.0 when I switched the default implementation of injectHTML to use document.write instead of document.body.innerHTML = ....

When calling injectHTML, scripts/stylesheets and other changes to head would get reset back to the default/initial contents of head instead of being left alone.

The documented behavior of injectHTML is "Set the contents of document.body." (and I think this makes sense). This PR removes the accidental additional behavior of resetting <head>.

Most of this PR is updating the tests to also snapshot the <head>, as well as one new test for an edge case to make sure that <head> is not modified or re-evaluated when injectHTML is called.

@calebeby calebeby merged commit f124a5a into main Dec 19, 2022
@calebeby calebeby deleted the injecthtml-dont-reset-head branch December 19, 2022 20:29
@github-actions github-actions bot mentioned this pull request Dec 19, 2022
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.

2 participants