diff --git a/src/lazy-define.ts b/src/lazy-define.ts index 0e603ee..016b886 100644 --- a/src/lazy-define.ts +++ b/src/lazy-define.ts @@ -85,15 +85,12 @@ export function lazyDefine(object: Record void>): void export function lazyDefine(tagName: string, callback: () => void): void export function lazyDefine(tagNameOrObj: string | Record void>, singleCallback?: () => void) { if (typeof tagNameOrObj === 'string' && singleCallback) { - if (!dynamicElements.has(tagNameOrObj)) dynamicElements.set(tagNameOrObj, new Set<() => void>()) - dynamicElements.get(tagNameOrObj)!.add(singleCallback) - } else { - for (const [tagName, callback] of Object.entries(tagNameOrObj)) { - if (!dynamicElements.has(tagName)) dynamicElements.set(tagName, new Set<() => void>()) - dynamicElements.get(tagName)!.add(callback) - } + tagNameOrObj = {[tagNameOrObj]: singleCallback} + } + for (const [tagName, callback] of Object.entries(tagNameOrObj)) { + if (!dynamicElements.has(tagName)) dynamicElements.set(tagName, new Set<() => void>()) + dynamicElements.get(tagName)!.add(callback) } - observe(document) }