Skip to content

Commit

Permalink
fix(element): correctly respond to object params assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Sep 21, 2023
1 parent 2f65e89 commit f23c742
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/components-shared/get-element-params.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attrToProp, extend } from './utils.mjs';
import { attrToProp, extend, isObject } from './utils.mjs';
import { paramsList } from './params-list.mjs';
import defaults from '../core/defaults.mjs';

Expand Down Expand Up @@ -66,7 +66,7 @@ function getParams(element, propName, propValue) {
// Attributes
const attrsList = [...element.attributes];
if (typeof propName === 'string' && typeof propValue !== 'undefined') {
attrsList.push({ name: propName, value: propValue });
attrsList.push({ name: propName, value: isObject(propValue) ? { ...propValue } : propValue });
}
attrsList.forEach((attr) => {
const moduleParam = modulesParamsList.filter(
Expand All @@ -84,11 +84,11 @@ function getParams(element, propName, propValue) {
const name = attrToProp(attr.name);
if (!allowedParams.includes(name)) return;
const value = formatValue(attr.value);
if (passedParams[name] && modulesParamsList.includes(attr.name)) {
if (passedParams[name] && modulesParamsList.includes(attr.name) && !isObject(value)) {
if (passedParams[name].constructor !== Object) {
passedParams[name] = {};
}
passedParams[name].enabled = value;
passedParams[name].enabled = !!value;
} else {
passedParams[name] = value;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components-shared/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ function isObject(o) {
typeof o === 'object' &&
o !== null &&
o.constructor &&
Object.prototype.toString.call(o).slice(8, -1) === 'Object'
Object.prototype.toString.call(o).slice(8, -1) === 'Object' &&
!o.__swiper__
);
}

Expand Down

0 comments on commit f23c742

Please sign in to comment.