Skip to content

Commit 2ef1ff5

Browse files
committed
fix(element): correctly respond to object params assignment
1 parent 908becc commit 2ef1ff5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/components-shared/get-element-params.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { attrToProp, extend } from './utils.mjs';
1+
import { attrToProp, extend, isObject } from './utils.mjs';
22
import { paramsList } from './params-list.mjs';
33
import defaults from '../core/defaults.mjs';
44

@@ -66,7 +66,7 @@ function getParams(element, propName, propValue) {
6666
// Attributes
6767
const attrsList = [...element.attributes];
6868
if (typeof propName === 'string' && typeof propValue !== 'undefined') {
69-
attrsList.push({ name: propName, value: propValue });
69+
attrsList.push({ name: propName, value: isObject(propValue) ? { ...propValue } : propValue });
7070
}
7171
attrsList.forEach((attr) => {
7272
const moduleParam = modulesParamsList.filter(
@@ -84,11 +84,11 @@ function getParams(element, propName, propValue) {
8484
const name = attrToProp(attr.name);
8585
if (!allowedParams.includes(name)) return;
8686
const value = formatValue(attr.value);
87-
if (passedParams[name] && modulesParamsList.includes(attr.name)) {
87+
if (passedParams[name] && modulesParamsList.includes(attr.name) && !isObject(value)) {
8888
if (passedParams[name].constructor !== Object) {
8989
passedParams[name] = {};
9090
}
91-
passedParams[name].enabled = value;
91+
passedParams[name].enabled = !!value;
9292
} else {
9393
passedParams[name] = value;
9494
}

src/components-shared/utils.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ function isObject(o) {
33
typeof o === 'object' &&
44
o !== null &&
55
o.constructor &&
6-
Object.prototype.toString.call(o).slice(8, -1) === 'Object'
6+
Object.prototype.toString.call(o).slice(8, -1) === 'Object' &&
7+
!o.__swiper__
78
);
89
}
910

0 commit comments

Comments
 (0)