Skip to content

Commit e595a03

Browse files
committed
chore: version, cl, build
1 parent 8d52c91 commit e595a03

9 files changed

+138
-8
lines changed

Diff for: CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## v2.6.10
2+
3+
> `2024-09-16`
4+
5+
### 🐞 Bug Fixes
6+
- Option should display as selected even when value is an object
7+
8+
### 🎉 Feature
9+
- Optimization (🙏 @bettysteger)
10+
111
## v2.6.9
212

313
> `2024-07-29`

Diff for: dist/multiselect.global.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/multiselect.js

+41-1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,43 @@ function arraysEqual (array1, array2) {
243243
})
244244
}
245245

246+
/* istanbul ignore next */
247+
const objectsEqual = (obj1, obj2) => {
248+
// If both are strictly equal, return true
249+
if (obj1 === obj2) {
250+
return true
251+
}
252+
253+
// If either is not an object or is null, return false (handles primitive types and null)
254+
if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) {
255+
return false
256+
}
257+
258+
// Get the keys of both objects
259+
const keys1 = Object.keys(obj1);
260+
const keys2 = Object.keys(obj2);
261+
262+
// If they have a different number of keys, they're not equal
263+
if (keys1.length !== keys2.length) {
264+
return false
265+
}
266+
267+
// Compare each key-value pair recursively
268+
for (let key of keys1) {
269+
// Check if both objects have the same key
270+
if (!keys2.includes(key)) {
271+
return false
272+
}
273+
274+
// Recursively compare the values
275+
if (!objectsEqual(obj1[key], obj2[key])) {
276+
return false
277+
}
278+
}
279+
280+
return true
281+
};
282+
246283
function useOptions (props, context, dep)
247284
{
248285
const {
@@ -563,7 +600,10 @@ function useOptions (props, context, dep)
563600

564601
switch (mode.value) {
565602
case 'single':
566-
return !isNullish(iv.value) && iv.value[valueProp.value] == option[valueProp.value]
603+
return !isNullish(iv.value) && (
604+
iv.value[valueProp.value] == option[valueProp.value] ||
605+
(typeof iv.value[valueProp.value] === 'object' && typeof option[valueProp.value] === 'object' && objectsEqual(iv.value[valueProp.value], option[valueProp.value]))
606+
)
567607

568608
case 'tags':
569609
case 'multiple':

Diff for: dist/multiselect.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/multiselect.mjs

+41-1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,43 @@ function arraysEqual (array1, array2) {
243243
})
244244
}
245245

246+
/* istanbul ignore next */
247+
const objectsEqual = (obj1, obj2) => {
248+
// If both are strictly equal, return true
249+
if (obj1 === obj2) {
250+
return true
251+
}
252+
253+
// If either is not an object or is null, return false (handles primitive types and null)
254+
if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) {
255+
return false
256+
}
257+
258+
// Get the keys of both objects
259+
const keys1 = Object.keys(obj1);
260+
const keys2 = Object.keys(obj2);
261+
262+
// If they have a different number of keys, they're not equal
263+
if (keys1.length !== keys2.length) {
264+
return false
265+
}
266+
267+
// Compare each key-value pair recursively
268+
for (let key of keys1) {
269+
// Check if both objects have the same key
270+
if (!keys2.includes(key)) {
271+
return false
272+
}
273+
274+
// Recursively compare the values
275+
if (!objectsEqual(obj1[key], obj2[key])) {
276+
return false
277+
}
278+
}
279+
280+
return true
281+
};
282+
246283
function useOptions (props, context, dep)
247284
{
248285
const {
@@ -563,7 +600,10 @@ function useOptions (props, context, dep)
563600

564601
switch (mode.value) {
565602
case 'single':
566-
return !isNullish(iv.value) && iv.value[valueProp.value] == option[valueProp.value]
603+
return !isNullish(iv.value) && (
604+
iv.value[valueProp.value] == option[valueProp.value] ||
605+
(typeof iv.value[valueProp.value] === 'object' && typeof option[valueProp.value] === 'object' && objectsEqual(iv.value[valueProp.value], option[valueProp.value]))
606+
)
567607

568608
case 'tags':
569609
case 'multiple':

Diff for: dist/multiselect.vue2.global.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/multiselect.vue2.js

+41-1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,43 @@ function arraysEqual (array1, array2) {
243243
})
244244
}
245245

246+
/* istanbul ignore next */
247+
const objectsEqual = (obj1, obj2) => {
248+
// If both are strictly equal, return true
249+
if (obj1 === obj2) {
250+
return true
251+
}
252+
253+
// If either is not an object or is null, return false (handles primitive types and null)
254+
if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) {
255+
return false
256+
}
257+
258+
// Get the keys of both objects
259+
const keys1 = Object.keys(obj1);
260+
const keys2 = Object.keys(obj2);
261+
262+
// If they have a different number of keys, they're not equal
263+
if (keys1.length !== keys2.length) {
264+
return false
265+
}
266+
267+
// Compare each key-value pair recursively
268+
for (let key of keys1) {
269+
// Check if both objects have the same key
270+
if (!keys2.includes(key)) {
271+
return false
272+
}
273+
274+
// Recursively compare the values
275+
if (!objectsEqual(obj1[key], obj2[key])) {
276+
return false
277+
}
278+
}
279+
280+
return true
281+
};
282+
246283
function useOptions (props, context, dep)
247284
{
248285
const {
@@ -563,7 +600,10 @@ function useOptions (props, context, dep)
563600

564601
switch (mode.value) {
565602
case 'single':
566-
return !isNullish(iv.value) && iv.value[valueProp.value] == option[valueProp.value]
603+
return !isNullish(iv.value) && (
604+
iv.value[valueProp.value] == option[valueProp.value] ||
605+
(typeof iv.value[valueProp.value] === 'object' && typeof option[valueProp.value] === 'object' && objectsEqual(iv.value[valueProp.value], option[valueProp.value]))
606+
)
567607

568608
case 'tags':
569609
case 'multiple':

Diff for: dist/multiselect.vue2.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vueform/multiselect",
3-
"version": "2.6.9",
3+
"version": "2.6.10",
44
"private": false,
55
"description": "Vue 3 multiselect component with single select, multiselect and tagging options.",
66
"license": "MIT",

0 commit comments

Comments
 (0)