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

[Bug] No const support in older browsers #339

Closed
pvdstel opened this issue Aug 8, 2018 · 2 comments
Closed

[Bug] No const support in older browsers #339

pvdstel opened this issue Aug 8, 2018 · 2 comments

Comments

@pvdstel
Copy link

pvdstel commented Aug 8, 2018

Occurs in v0.22.0.

Do you want to request a feature or report a bug?
Report a bug.

What is the current behavior?
TypeError: undefined is not an object (evaluating 'e.setAttribute').

In fc24512, support for nonces was added. The nonce variable is declared using const. This const is causing errors in browsers not supporting it.

The Webpack-minified createStyleElement function looks as follows (basic formatting applied):

function h(e) {
  var t = document.createElement("style");
  if (void 0 === e.attrs.type && (e.attrs.type = "text/css"), void 0 === e.attrs.nonce) {
    const t = function () { // t is reassigned
      0;
      return n.nc
    }();
    t && (e.attrs.nonce = t)
  }
  return m(t, e.attrs), // m is addAttrs
    f(e, t),
    t
}

It appears that t (style) is reassigned to a function. As this value is passed to addAttrs) it now no longer has a setAttribute function.

What is the expected behavior?

No TypeError is thrown on older browsers. Newer browsers are fine.

Please mention other relevant information such as your webpack version, Node.js version and Operating System.

Webpack v4.16.5
Node v8.10.0
OS: Windows 10 version 1803

@alexander-akait
Copy link
Member

Already fixed #338, release will be soon

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Aug 8, 2018

Fixed by #338 and released in v0.22.1 🎉

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

No branches or pull requests

3 participants