ant-design-vue/components/_util/warning.js

39 lines
831 B
JavaScript
Raw Normal View History

2019-08-28 22:56:51 +08:00
/* eslint-disable no-console */
let warned = {};
2017-12-07 18:33:33 +08:00
2019-08-28 22:56:51 +08:00
export function warning(valid, message) {
// Support uglify
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
console.error(`Warning: ${message}`);
}
}
export function note(valid, message) {
// Support uglify
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
console.warn(`Note: ${message}`);
}
}
export function resetWarned() {
warned = {};
}
2019-08-29 22:50:53 +08:00
export function call(method, valid, message) {
2018-01-16 19:15:07 +08:00
if (!valid && !warned[message]) {
2019-08-28 22:56:51 +08:00
method(false, message);
2019-01-12 11:33:27 +08:00
warned[message] = true;
2017-12-07 18:33:33 +08:00
}
2019-08-28 22:56:51 +08:00
}
export function warningOnce(valid, message) {
call(warning, valid, message);
}
export function noteOnce(valid, message) {
call(note, valid, message);
}
export default warningOnce;
/* eslint-enable */