-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
gatsby-remark-autolink-headers: SSR assumes let keyword is available #21058
Comments
This was referenced Jan 31, 2020
IE: crash on "let" keyword (related to gatsby-remark-autolink-headers)
nextstrain/nextstrain.org#113
Closed
gatsbybot
pushed a commit
that referenced
this issue
Jan 31, 2020
…21083) * fix(gatsby-remark-autolink-headers): remove hardcoded "let" keyword This resolves #21058 In `gatsby-remark-autolink-headers`, this code snippet https://github.com/gatsbyjs/gatsby/blob/5e7ccd13f79e54036869a72e423bf7cf4ab486af/packages/gatsby-remark-autolink-headers/src/gatsby-ssr.js#L51-L67 contains 2 instances of hardcoded "let" keyword, which is being rendered into the HTML without transpilation. This makes the script crash in old browsers, such as IE (all versions). This commit replaces "let" to "var". Care should be taken because this is an unsafe transformation, due to var scope hoisting. My initial tests show that everything is good. I initially encountered this error while porting https://nextstrain.org to IE: nextstrain/nextstrain.org#113 This fix should help scientists researching 2019-nCoV outbreak (some of them still use Internet Explorer) * fix(gatsby-remark-autolink-headers): add a comment explaining "let" keyword removal #21058 #21083
ehowey
pushed a commit
to ehowey/gatsby
that referenced
this issue
Jan 31, 2020
…atsbyjs#21083) * fix(gatsby-remark-autolink-headers): remove hardcoded "let" keyword This resolves gatsbyjs#21058 In `gatsby-remark-autolink-headers`, this code snippet https://github.com/gatsbyjs/gatsby/blob/5e7ccd13f79e54036869a72e423bf7cf4ab486af/packages/gatsby-remark-autolink-headers/src/gatsby-ssr.js#L51-L67 contains 2 instances of hardcoded "let" keyword, which is being rendered into the HTML without transpilation. This makes the script crash in old browsers, such as IE (all versions). This commit replaces "let" to "var". Care should be taken because this is an unsafe transformation, due to var scope hoisting. My initial tests show that everything is good. I initially encountered this error while porting https://nextstrain.org to IE: nextstrain/nextstrain.org#113 This fix should help scientists researching 2019-nCoV outbreak (some of them still use Internet Explorer) * fix(gatsby-remark-autolink-headers): add a comment explaining "let" keyword removal gatsbyjs#21058 gatsbyjs#21083
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I opened PR with a fix here:
#21083
Description
I initially encountered this error while porting https://nextstrain.org to IE:
nextstrain/nextstrain.org#113
When
gatsby-remark-autolink-headers
is enabled, Internet Explorer 10-11 will fail withpointing to the line 6 in the snippet below:
As you see, the code contains
let
keyword and is not properly transpiled (Or, also, you know, not minimized and whatnot ;) )The snippet comes from a string hardcoded in
packages/gatsby-remark-autolink-headers/src/gatsby-ssr.js
:gatsby/packages/gatsby-remark-autolink-headers/src/gatsby-ssr.js
Lines 51 to 67 in 5e7ccd1
Note that the browser version does not containlet
:Note that the browser version does contain
let
too, but is transpiled correctly intovar
. Here is the source:gatsby/packages/gatsby-remark-autolink-headers/src/gatsby-browser.js
Lines 3 to 20 in 5e7ccd1
Steps to reproduce
Open Gatsby-generated HTML with Internet Explorer (any version) or any other browser that does not support
let
keyword.Expected result
There should be no errors in console and page should be rendered in the browser.
Actual result
There is an error in console and page is not rendered in the browser.
Environment
The text was updated successfully, but these errors were encountered: