UNPKG

552 BJavaScriptView Raw
1/* @flow */
2
3import { warn } from 'core/util/index'
4
5export * from './attrs'
6export * from './class'
7export * from './element'
8
9/**
10 * Query an element selector if it's not an element already.
11 */
12export function query (el: string | Element): Element {
13 if (typeof el === 'string') {
14 const selected = document.querySelector(el)
15 if (!selected) {
16 process.env.NODE_ENV !== 'production' && warn(
17 'Cannot find element: ' + el
18 )
19 return document.createElement('div')
20 }
21 return selected
22 } else {
23 return el
24 }
25}