warn.js
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { IS_BROWSER, HAS_PROMISE_SUPPORT, HAS_MUTATION_OBSERVER_SUPPORT } from '../constants/env'
import { getNoWarn } from './env'
/**
* Log a warning message to the console with BootstrapVue formatting
* @param {string} message
*/
export const warn = (message, source = null) => /* istanbul ignore next */ {
if (!getNoWarn()) {
console.warn(`[BootstrapVue warn]: ${source ? `${source} - ` : ''}${message}`)
}
}
/**
* Warn when no Promise support is given
* @param {string} source
* @returns {boolean} warned
*/
export const warnNotClient = source => {
/* istanbul ignore else */
if (IS_BROWSER) {
return false
} else {
warn(`${source}: Can not be called during SSR.`)
return true
}
}
/**
* Warn when no Promise support is given
* @param {string} source
* @returns {boolean} warned
*/
export const warnNoPromiseSupport = source => {
/* istanbul ignore else */
if (HAS_PROMISE_SUPPORT) {
return false
} else {
warn(`${source}: Requires Promise support.`)
return true
}
}
/**
* Warn when no MutationObserver support is given
* @param {string} source
* @returns {boolean} warned
*/
export const warnNoMutationObserverSupport = source => {
/* istanbul ignore else */
if (HAS_MUTATION_OBSERVER_SUPPORT) {
return false
} else {
warn(`${source}: Requires MutationObserver support.`)
return true
}
}