diff --git a/src/components/core/core-class.js b/src/components/core/core-class.js index 1e5692163..f8f22b80d 100644 --- a/src/components/core/core-class.js +++ b/src/components/core/core-class.js @@ -49,7 +49,11 @@ class Swiper { constructor(...args) { let el; let params; - if (args.length === 1 && args[0].constructor && args[0].constructor === Object) { + if ( + args.length === 1 && + args[0].constructor && + Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object' + ) { params = args[0]; } else { [el, params] = args; diff --git a/src/react/utils.js b/src/react/utils.js index 7993804ff..0378af8df 100644 --- a/src/react/utils.js +++ b/src/react/utils.js @@ -1,5 +1,10 @@ function isObject(o) { - return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; + return ( + typeof o === 'object' && + o !== null && + o.constructor && + Object.prototype.toString.call(o).slice(8, -1) === 'Object' + ); } function extend(target, src) { diff --git a/src/svelte/utils.js b/src/svelte/utils.js index 7993804ff..0378af8df 100644 --- a/src/svelte/utils.js +++ b/src/svelte/utils.js @@ -1,5 +1,10 @@ function isObject(o) { - return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; + return ( + typeof o === 'object' && + o !== null && + o.constructor && + Object.prototype.toString.call(o).slice(8, -1) === 'Object' + ); } function extend(target, src) { diff --git a/src/utils/utils.js b/src/utils/utils.js index 4c9348634..c5b8d2814 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -85,7 +85,12 @@ function getTranslate(el, axis = 'x') { return curTransform || 0; } function isObject(o) { - return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; + return ( + typeof o === 'object' && + o !== null && + o.constructor && + Object.prototype.toString.call(o).slice(8, -1) === 'Object' + ); } function extend(...args) { const to = Object(args[0]); diff --git a/src/vue/utils.js b/src/vue/utils.js index e2e895d0c..a6839f045 100644 --- a/src/vue/utils.js +++ b/src/vue/utils.js @@ -1,5 +1,10 @@ function isObject(o) { - return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; + return ( + typeof o === 'object' && + o !== null && + o.constructor && + Object.prototype.toString.call(o).slice(8, -1) === 'Object' + ); } function extend(target, src) {