mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-22 16:00:39 +01:00
fix(Link): consistent behavior between nuxt, vue and inertia (#4134)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { reactivePick } from '@vueuse/core'
|
||||
import { isEqual, diff } from 'ohash/utils'
|
||||
import type { LinkProps } from '../types'
|
||||
|
||||
export function pickLinkProps(link: LinkProps & { [key: string]: any }) {
|
||||
@@ -19,3 +20,17 @@ export function pickLinkProps(link: LinkProps & { [key: string]: any }) {
|
||||
|
||||
return reactivePick(link, ...propsToInclude)
|
||||
}
|
||||
|
||||
export function isPartiallyEqual(item1: any, item2: any) {
|
||||
const diffedKeys = diff(item1, item2).reduce((filtered, q) => {
|
||||
if (q.type === 'added') {
|
||||
filtered.add(q.key)
|
||||
}
|
||||
return filtered
|
||||
}, new Set<string>())
|
||||
|
||||
const item1Filtered = Object.fromEntries(Object.entries(item1).filter(([key]) => !diffedKeys.has(key)))
|
||||
const item2Filtered = Object.fromEntries(Object.entries(item2).filter(([key]) => !diffedKeys.has(key)))
|
||||
|
||||
return isEqual(item1Filtered, item2Filtered)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user