diff --git a/src/mount.ts b/src/mount.ts index 3e4016943..13348217e 100644 --- a/src/mount.ts +++ b/src/mount.ts @@ -86,15 +86,18 @@ export function mount( el.id = MOUNT_ELEMENT_ID if (options?.attachTo) { - const to = isString(options.attachTo) - ? document.querySelector(options.attachTo) - : options.attachTo - - if (!to) { - throw new Error( - `Unable to find the element matching the selector ${options.attachTo} given as the \`attachTo\` option` - ) + let to: Element + if (typeof options.attachTo === 'string') { + to = document.querySelector(options.attachTo) + if (!to) { + throw new Error( + `Unable to find the element matching the selector ${options.attachTo} given as the \`attachTo\` option` + ) + } + } else { + to = options.attachTo } + to.appendChild(el) }