Skip to content

Commit

Permalink
fix hmr dispose of styleEl (#1425)
Browse files Browse the repository at this point in the history
  • Loading branch information
solenoid authored Oct 29, 2020
1 parent 48b99c0 commit 0fda79d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions snowpack/src/build/build-import-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,15 @@ ${
hmr
? `
import * as __SNOWPACK_HMR_API__ from '${getMetaUrlPath('hmr-client.js', config)}';
import.meta.hot = __SNOWPACK_HMR_API__.createHotContext(import.meta.url);
import.meta.hot.dispose(() => {
document && document.head.removeChild(styleEl);
});\n` : ``}
import.meta.hot = __SNOWPACK_HMR_API__.createHotContext(import.meta.url);\n` : ``}
// [snowpack] add styles to the page (skip if no document exists)
if (typeof document !== 'undefined') {
if (typeof document !== 'undefined') {${
hmr
? `
import.meta.hot.dispose(() => {
document && document.head.removeChild(styleEl);
});\n`
: ``}
const styleEl = document.createElement("style");
const codeEl = document.createTextNode(code);
styleEl.type = 'text/css';
Expand Down

1 comment on commit 0fda79d

@vercel
Copy link

@vercel vercel bot commented on 0fda79d Oct 29, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.