nathantsoi / vue-native-websocket

native websocket with vuex integration
943 stars 162 forks source link

Object.seal will throw an error in IE11 #75

Open Alex-Sokolov opened 5 years ago

Alex-Sokolov commented 5 years ago

Now in build (https://raw.githubusercontent.com/nathantsoi/vue-native-websocket/master/dist/build.js) there is Object.seal(this.$options.sockets) using

IE11 doesn't know what it is & will throw error. I think need to include polyfill for Object.seal or mention about it in readme

larsmars commented 5 years ago

I have the same: Please make a work around for IE11

[Vue warn]: Error in created hook: "TypeError: Object.seal: argument is not an Object"

"vue": "^2.5.17", "vue-native-websocket": "^2.0.9", "@vue/cli-plugin-babel": "^3.0.1", "@vue/cli-plugin-eslint": "^3.0.1", "@vue/cli-plugin-unit-jest": "^3.0.1", "@vue/cli-service": "^3.0.1",

Jabbar2010 commented 5 years ago

放弃这个插件吧,ie11g等不支持Proxy的逻辑作者没有实现好,无法使用

larsmars commented 5 years ago

This is not a solution and this bug should not be marked as "fixed" this is a work around/hack to make the application not crash into a ditch if using IE11:

Only mount the plugin if modern browser

In your main.js file:

import VueNativeSock from 'vue-native-websocket'

if (!(window.ActiveXObject) && 'ActiveXObject' in window) {
  store.dispatch('app/setModernBrowser', false)
} else {
  Vue.use(VueNativeSock, wsUrl(), {
    store: store,
    connectManually: true,
    format: 'json'
  })
  store.dispatch('app/setModernBrowser', true)
}
PrinceMagbanua commented 5 years ago

@larsmars this guy made it work without using Proxy object. Tested it and it works properly. https://www.npmjs.com/package/vue-native-websocket-es5

larsmars commented 5 years ago

@larsmars this guy made it work without using Proxy object. Tested it and it works properly. https://www.npmjs.com/package/vue-native-websocket-es5

What did he do? That package ref. to this repo. Will it work properly on IE11?

paulinekorkina commented 5 years ago

I've fixed the same error with @babel/polyfill

Perlover commented 3 years ago

Now in build (https://raw.githubusercontent.com/nathantsoi/vue-native-websocket/master/dist/build.js) there is Object.seal(this.$options.sockets) using

IE11 doesn't know what it is & will throw error. I think need to include polyfill for Object.seal or mention about it in readme

I think it's because the this.$options.sockets is not the object (i think it's undefined) and IE11 follows to ES5 code:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal#Non-object_coercion