Skip to content

[Bug] isPlainObj fn not compatible for IE11 #1745

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

Closed
binarykitchen opened this issue Oct 31, 2019 · 2 comments · Fixed by #1833
Closed

[Bug] isPlainObj fn not compatible for IE11 #1745

binarykitchen opened this issue Oct 31, 2019 · 2 comments · Fixed by #1833
Labels
Milestone

Comments

@binarykitchen
Copy link

This implementation is breaking on IE11

  function isPlainObj(value) {
    return (
      value &&
      (typeof value.constructor !== 'function' ||
        value.constructor.name === 'Object')
    );
  }

Always returns false.

Refer to https://stackoverflow.com/questions/25140723/constructor-name-is-undefined-in-internet-explorer

@binarykitchen
Copy link
Author

A workaround would be to polyfill that with

  if ('name' in Object.constructor.prototype === false) {
    Object.defineProperty(Object.constructor.prototype, 'name', {
      get: function () {
        return this.toString().trim().replace(/^\S+\s+(\w+)[\S\s]+$/, '$1')
      }
    })
  }

@jdeniau
Copy link
Member

jdeniau commented Jun 29, 2021

Thank you for your bug report. The immutable-js oss fork will soon be merged and a fix for this issue has been included in #1833. Once this PR is merged, this issue will be resolved in the main branch. We will then do our best to to release the 4.0.0 version.

Commit reference: f3a6d5c

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

Successfully merging a pull request may close this issue.

3 participants