Skip to content

Commit

Permalink
fix: isObject cross window
Browse files Browse the repository at this point in the history
  • Loading branch information
vltansky committed Mar 24, 2021
1 parent 95b5dfe commit 7c36077
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/core/core-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/react/utils.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/svelte/utils.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
7 changes: 6 additions & 1 deletion src/vue/utils.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 7c36077

Please sign in to comment.