1 | /* @flow */
|
2 |
|
3 | import { warn } from 'core/util/index'
|
4 |
|
5 | export * from './attrs'
|
6 | export * from './class'
|
7 | export * from './element'
|
8 |
|
9 | /**
|
10 | * Query an element selector if it's not an element already.
|
11 | */
|
12 | export 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 | }
|