Skip to content

Commit 79376f3

Browse files
authored
Merge pull request #120 from vuejs/types/fix-ts-error
types: fix typing for options.attachTo
2 parents fe21a93 + 8e36df4 commit 79376f3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/mount.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,18 @@ export function mount(
9999
el.id = MOUNT_ELEMENT_ID
100100

101101
if (options?.attachTo) {
102-
const to = isString(options.attachTo)
103-
? document.querySelector(options.attachTo)
104-
: options.attachTo
105-
106-
if (!to) {
107-
throw new Error(
108-
`Unable to find the element matching the selector ${options.attachTo} given as the \`attachTo\` option`
109-
)
102+
let to: Element
103+
if (typeof options.attachTo === 'string') {
104+
to = document.querySelector(options.attachTo)
105+
if (!to) {
106+
throw new Error(
107+
`Unable to find the element matching the selector ${options.attachTo} given as the \`attachTo\` option`
108+
)
109+
}
110+
} else {
111+
to = options.attachTo
110112
}
113+
111114
to.appendChild(el)
112115
}
113116

0 commit comments

Comments
 (0)