UNPKG

@gitlab/ui

Version:
46 lines (41 loc) 1.18 kB
import { IS_BROWSER, HAS_MUTATION_OBSERVER_SUPPORT } from '../constants/env'; import { getNoWarn } from './env'; /** * Log a warning message to the console with BootstrapVue formatting * @param {string} message */ const warn = function (message) /* istanbul ignore next */{ let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; if (!getNoWarn()) { console.warn(`[BootstrapVue warn]: ${source ? `${source} - ` : ''}${message}`); } }; /** * Warn when no Promise support is given * @param {string} source * @returns {boolean} warned */ 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 MutationObserver support is given * @param {string} source * @returns {boolean} warned */ const warnNoMutationObserverSupport = source => { /* istanbul ignore else */ if (HAS_MUTATION_OBSERVER_SUPPORT) { return false; } else { warn(`${source}: Requires MutationObserver support.`); return true; } }; export { warn, warnNoMutationObserverSupport, warnNotClient };