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

Bootstrap-vue does not work with IE11 due to deepFreeze #3525

Closed
jeuxjeux20 opened this issue Jun 15, 2019 · 5 comments · Fixed by #3526
Closed

Bootstrap-vue does not work with IE11 due to deepFreeze #3525

jeuxjeux20 opened this issue Jun 15, 2019 · 5 comments · Fixed by #3526

Comments

@jeuxjeux20
Copy link

Describe the bug

Basically, IE11 throws an error: "Symbol is undefined", on the src/utils/object.js file with deepFreeze, which is the transpiled version of for (let prop of props):

export const deepFreeze = obj => {
  // Retrieve the property names defined on object
  const props = getOwnPropertyNames(obj)
  // Freeze properties before freezing self
  for (let prop of props) {
    let value = obj[prop]
    obj[prop] = value && isObject(value) ? deepFreeze(value) : value
  }
  return freeze(obj)
}

The transpiled code in boostrap-vue.esm.js is

var deepFreeze = function deepFreeze(obj) {
  // Retrieve the property names defined on object
  var props = getOwnPropertyNames(obj); // Freeze properties before freezing self

  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    for (var _iterator = props[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      var prop = _step.value;
      var value = obj[prop];
      obj[prop] = value && isObject(value) ? deepFreeze(value) : value;
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return != null) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError; /* this is where the error is */
      }
    }
  }
  return freeze(obj);
};

This is new to the rc23 version.

Steps to reproduce the bug

  1. Use bootstrap-vue
  2. Use internet explorer

Expected behavior

The error should not happen.

Versions

Libraries:

  • BootstrapVue: 2.0.0-rc23
  • Bootstrap: 4.3.1
  • Vue: 2.6.10

Environment:

  • Device: PC
  • OS: Windows 10
  • Browser: Internet Explorer
  • Version: 11 (obviously :D)
@tmorehouse
Copy link
Member

Are you importing the latest polyfills for IE (either from polyfill.io or similar)?

@tmorehouse
Copy link
Member

We might be able to re-work the routine to make it transpile a bit better.

tmorehouse added a commit that referenced this issue Jun 15, 2019
Avoid using the `of` operator, as it transpiles into a bunch of helper code (which uses Symbol, of which IE 11 needs a polyfill for)

Since we are only deep-freezing the default BootstrapVue config (to prevent possible mutations), we can switch to `Object.keys` and `.forEach()` to simplify the code.

Closes #3525
@tmorehouse
Copy link
Member

tmorehouse commented Jun 15, 2019

@jeuxjeux20 The docs recommended polyfill(s) include a polyfill for IE 11 Symbol

https://bootstrap-vue.js.org/docs#js (using @babel/polyfill)

or

https://bootstrap-vue.js.org/docs#browser (using polyfill.io)

@jeuxjeux20
Copy link
Author

Yeah i got it to work with a polyfill 👏, though @babel/polyfill was deprecated, i used core-js instead, by importing it: import "core-js"; (typescript) or require('core-js') (javascript)

jacobmllr95 pushed a commit that referenced this issue Jun 17, 2019
* fix(utils/deepFreeze): avoid using `of` operator (closes #3525)

Avoid using the `of` operator, as it transpiles into a bunch of helper code (which uses Symbol, of which IE 11 needs a polyfill for)

Since we are only deep-freezing the default BootstrapVue config (to prevent possible mutations), we can switch to `Object.keys` and `.forEach()` to simplify the code.

Closes #3525

* Update config-set.js

* Update object.js
@Owumaro
Copy link

Owumaro commented Jun 18, 2019

While #3526 solved the IE11 issue with deepFreeze, I'm still having the same issue with the BNavItemDropdown component when I click on it.

I couldn't find why this happens as IE11 doesn't provide much information...

[Vue warn]: Error in v-on handler: "ReferenceError: 'Symbol' is undefined"

Stack:
"ReferenceError: 'Symbol' is undefined
at _iterableToArray (http://10.0.2.2:3000/packs/js/application-af27a7aaa11cf03c733b.js:14565:3)
at _toConsumableArray (http://10.0.2.2:3000/packs/js/application-af27a7aaa11cf03c733b.js:14557:3)
at Anonymous function (http://10.0.2.2:3000/packs/js/application-af27a7aaa11cf03c733b.js:14715:9)
at onClick (http://10.0.2.2:3000/packs/js/application-af27a7aaa11cf03c733b.js:14712:7)
at invokeWithErrorHandling (http://10.0.2.2:3000/packs/js/application-af27a7aaa11cf03c733b.js:66371:5)
at invoker (http://10.0.2.2:3000/packs/js/application-af27a7aaa11cf03c733b.js:66707:7)"

I also noticed there is no issue with the BDropdown component.

Finally the BNavItemDropdown component was working fine in IE11 without the Symbol polyfill when I was using bootstrap-vue@2.0.0-rc.19. Seems like it stopped working with rc.20.

That's all the information I could get, hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants