diff --git a/packages/design/src/Popover.vue b/packages/design/src/Popover.vue index 7c6d66a59..9bee8834e 100644 --- a/packages/design/src/Popover.vue +++ b/packages/design/src/Popover.vue @@ -46,7 +46,6 @@ const popoverVisible = ref(false); const visibleWatch = watch( () => props.visible, (visible) => { - console.log(visible); if (typeof visible === 'undefined') { nextTick(() => { visibleWatch(); diff --git a/packages/utils/src/dom.ts b/packages/utils/src/dom.ts index 55cb4e249..b9bec3094 100644 --- a/packages/utils/src/dom.ts +++ b/packages/utils/src/dom.ts @@ -123,11 +123,26 @@ export const calcValueByFontsize = (doc: Document | undefined, value: number) => return value; }; -export const getIdFromEl = () => (el?: HTMLElement | SVGElement | null) => el?.dataset?.tmagicId; - -export const getElById = () => (doc?: Document, id?: string | number) => - doc?.querySelector(`[data-tmagic-id=${id}]`) as HTMLElement; +const dslDomRelateConfig = { + getIdFromEl: (el?: HTMLElement | SVGElement | null) => el?.dataset?.tmagicId, + getElById: (doc?: Document, id?: string | number) => doc?.querySelector(`[data-tmagic-id="${id}"]`) as HTMLElement, + setIdToEl: (el: HTMLElement | SVGElement, id: string | number) => { + el.dataset.tmagicId = `${id}`; + }, +}; -export const setIdToEl = () => (el: HTMLElement | SVGElement, id: string | number) => { - el.dataset.tmagicId = `${id}`; +export const setDslDomRelateConfig = < + K extends keyof typeof dslDomRelateConfig, + T extends (typeof dslDomRelateConfig)[K], +>( + name: K, + value: T, +) => { + dslDomRelateConfig[name] = value; }; + +export const getIdFromEl = () => dslDomRelateConfig.getIdFromEl; + +export const getElById = () => dslDomRelateConfig.getElById; + +export const setIdToEl = () => dslDomRelateConfig.setIdToEl;