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

Object doesn't support property or method 'assign' #11

Closed
riksnelders opened this issue Nov 10, 2017 · 7 comments
Closed

Object doesn't support property or method 'assign' #11

riksnelders opened this issue Nov 10, 2017 · 7 comments
Labels

Comments

@riksnelders
Copy link

riksnelders commented Nov 10, 2017

IE error thrown.

in this function

while (sources.length > 0) {
   var source = sources.shift();
   if (isObject(source)) {
     for (var key in source) {
       if (isObject(source[key])) {
         target[key] = mergeDeep(target[key], source[key]);
       } else {
         Object.assign(target, defineProperty({}, key, source[key]));
       }
     }
   }
 }
 return target;
}

@grantcarthew
Copy link
Contributor

Try this pollyfill from MDN:

if (typeof Object.assign != 'function') {
  // Must be writable: true, enumerable: false, configurable: true
  Object.defineProperty(Object, "assign", {
    value: function assign(target, varArgs) { // .length of function is 2
      'use strict';
      if (target == null) { // TypeError if undefined or null
        throw new TypeError('Cannot convert undefined or null to object');
      }

      var to = Object(target);

      for (var index = 1; index < arguments.length; index++) {
        var nextSource = arguments[index];

        if (nextSource != null) { // Skip over if undefined or null
          for (var nextKey in nextSource) {
            // Avoid bugs when hasOwnProperty is shadowed
            if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
              to[nextKey] = nextSource[nextKey];
            }
          }
        }
      }
      return to;
    },
    writable: true,
    configurable: true
  });
}

@riksnelders
Copy link
Author

problem is , i have no idea where this code is. Just pasted it because thats where the error was thrown

@artemsky
Copy link
Owner

@riksnelders This code generated by webpack with target of 'ES5' for this part of code https://github.com/artemsky/vue-snotify/blob/master/src/util.js#L17

I'll try to do something with that in next release (soon)

@artemsky artemsky added the bug label Nov 10, 2017
@artemsky
Copy link
Owner

@riksnelders this polyfill should work with new release(in one day).

@chrisribe
Copy link

Currently having the same issue under IE Edge.
I am using the compiled version from the cdn: https://unpkg.com/vue-snotify@latest/vue-snotify.min.js

Something changed ?
Chris

@hafez-bsup
Copy link

I still get this error on vue-snotify 3.0.4.

@xianshenglu
Copy link

xianshenglu commented Sep 8, 2018

I solve kind of question by adding resolve('node_modules/vue-snotify') in build/webpack.base.conf.js

 {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [
          resolve('src'),
          resolve('test'),
          resolve('node_modules/webpack-dev-server/client'),
          resolve('node_modules/vue-snotify')
        ]
 },

also, I used import 'babel-polyfill' in main.js

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

No branches or pull requests

6 participants