Skip to content

Commit 8e36df4

Browse files
committed
refactor: move check inside if statement
1 parent 76d24be commit 8e36df4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/mount.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ export function mount(
8989
let to: Element
9090
if (typeof options.attachTo === 'string') {
9191
to = document.querySelector(options.attachTo)
92+
if (!to) {
93+
throw new Error(
94+
`Unable to find the element matching the selector ${options.attachTo} given as the \`attachTo\` option`
95+
)
96+
}
9297
} else {
9398
to = options.attachTo
9499
}
95100

96-
if (!to) {
97-
throw new Error(
98-
`Unable to find the element matching the selector ${options.attachTo} given as the \`attachTo\` option`
99-
)
100-
}
101101
to.appendChild(el)
102102
}
103103

0 commit comments

Comments
 (0)