mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-06 08:00:05 +00:00
[Refactor] Use util.clone in mergeIfValid (#2752)
This commit is contained in:
@@ -13,7 +13,7 @@ import type {
|
||||
import type { CanvasMouseEvent } from '@comfyorg/litegraph/dist/types/events'
|
||||
|
||||
import { app } from '@/scripts/app'
|
||||
import { applyTextReplacements } from '@/scripts/utils'
|
||||
import { applyTextReplacements, clone } from '@/scripts/utils'
|
||||
import { ComfyWidgets, addValueControlWidgets } from '@/scripts/widgets'
|
||||
import { useNodeDefStore } from '@/stores/nodeDefStore'
|
||||
import { useSettingStore } from '@/stores/settingStore'
|
||||
@@ -647,11 +647,7 @@ export function mergeIfValid(
|
||||
let customConfig: Record<string, unknown> | undefined
|
||||
const getCustomConfig = () => {
|
||||
if (!customConfig) {
|
||||
if (typeof structuredClone === 'undefined') {
|
||||
customConfig = JSON.parse(JSON.stringify(config1[1] ?? {}))
|
||||
} else {
|
||||
customConfig = structuredClone(config1[1] ?? {})
|
||||
}
|
||||
customConfig = clone(config1[1] ?? {})
|
||||
}
|
||||
return customConfig
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ function formatDate(text: string, date: Date) {
|
||||
})
|
||||
}
|
||||
|
||||
export function clone(obj: any) {
|
||||
export function clone<T>(obj: T): T {
|
||||
try {
|
||||
if (typeof structuredClone !== 'undefined') {
|
||||
return structuredClone(obj)
|
||||
|
||||
Reference in New Issue
Block a user