From f0e1ff7921db15a823a3457eccfe82a8d6fd3f48 Mon Sep 17 00:00:00 2001 From: Moein Date: Fri, 20 Nov 2020 23:22:16 +0100 Subject: [PATCH 1/2] fix(generic): fixes on usage of isUndefined in many components and form-text mixin --- src/components/calendar/calendar.js | 6 +++--- src/components/form-file/form-file.js | 3 +-- src/components/form-spinbutton/form-spinbutton.js | 4 ++-- src/components/form-tags/form-tags.js | 4 ++-- src/components/table/helpers/mixin-filtering.js | 4 ++-- src/mixins/form-text.js | 4 ++-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/components/calendar/calendar.js b/src/components/calendar/calendar.js index 19df7143e74..3ec7c108ef4 100644 --- a/src/components/calendar/calendar.js +++ b/src/components/calendar/calendar.js @@ -43,7 +43,7 @@ import { } from '../../utils/date' import { attemptBlur, attemptFocus, requestAF } from '../../utils/dom' import { stopEvent } from '../../utils/events' -import { isArray, isPlainObject, isString, isUndefined } from '../../utils/inspect' +import {isArray, isPlainObject, isString, isUndefinedOrNull} from '../../utils/inspect' import { isLocaleRTL } from '../../utils/locale' import { mathMax } from '../../utils/math' import { toInteger } from '../../utils/number' @@ -346,7 +346,7 @@ export const BCalendar = Vue.extend({ try { result = dateDisabledFn() } catch {} - return isUndefined(result) ? () => false : dateDisabledFn + return isUndefinedOrNull(result) ? () => false : dateDisabledFn }, // TODO: Change `dateInfoFn` to handle events and notes as well as classes computedDateInfoFn() { @@ -355,7 +355,7 @@ export const BCalendar = Vue.extend({ try { result = dateInfoFn() } catch {} - return isUndefined(result) ? () => ({}) : dateInfoFn + return isUndefinedOrNull(result) ? () => ({}) : dateInfoFn }, calendarLocale() { // This locale enforces the gregorian calendar (for use in formatter functions) diff --git a/src/components/form-file/form-file.js b/src/components/form-file/form-file.js index bfbfee33b6b..edec487f90f 100644 --- a/src/components/form-file/form-file.js +++ b/src/components/form-file/form-file.js @@ -15,7 +15,6 @@ import { isFile, isFunction, isNull, - isUndefined, isUndefinedOrNull } from '../../utils/inspect' import { File } from '../../utils/safe-types' @@ -280,7 +279,7 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({ try { result = fileNameFormatter() } catch {} - return isUndefined(result) ? this.defaultFileNameFormatter : fileNameFormatter + return isUndefinedOrNull(result) ? this.defaultFileNameFormatter : fileNameFormatter }, clonedFiles() { return cloneDeep(this.files) diff --git a/src/components/form-spinbutton/form-spinbutton.js b/src/components/form-spinbutton/form-spinbutton.js index bdb0ae25c03..561c9ce914a 100644 --- a/src/components/form-spinbutton/form-spinbutton.js +++ b/src/components/form-spinbutton/form-spinbutton.js @@ -13,7 +13,7 @@ import { arrayIncludes, concat } from '../../utils/array' import { makePropsConfigurable } from '../../utils/config' import { attemptBlur, attemptFocus } from '../../utils/dom' import { eventOnOff, stopEvent } from '../../utils/events' -import { isNull, isUndefined } from '../../utils/inspect' +import {isNull, isUndefinedOrNull} from '../../utils/inspect' import { isLocaleRTL } from '../../utils/locale' import { mathFloor, mathMax, mathPow, mathRound } from '../../utils/math' import { toFloat, toInteger } from '../../utils/number' @@ -227,7 +227,7 @@ export const BFormSpinbutton = /*#__PURE__*/ Vue.extend({ try { result = formatterFn() } catch {} - return isUndefined(result) ? this.defaultFormatter : formatterFn + return isUndefinedOrNull(result) ? this.defaultFormatter : formatterFn }, computedAttrs() { return { diff --git a/src/components/form-tags/form-tags.js b/src/components/form-tags/form-tags.js index 0000b13e82b..e323ced4c16 100644 --- a/src/components/form-tags/form-tags.js +++ b/src/components/form-tags/form-tags.js @@ -21,7 +21,7 @@ import { } from '../../utils/dom' import { stopEvent } from '../../utils/events' import { pick } from '../../utils/object' -import { isEvent, isNumber, isString, isUndefined } from '../../utils/inspect' +import {isEvent, isNumber, isString, isUndefinedOrNull} from '../../utils/inspect' import { escapeRegExp, toString, trim, trimLeft } from '../../utils/string' import formControlMixin, { props as formControlProps } from '../../mixins/form-control' import formSizeMixin, { props as formSizeProps } from '../../mixins/form-size' @@ -512,7 +512,7 @@ export const BFormTags = /*#__PURE__*/ Vue.extend({ try { result = tagValidator() } catch {} - return isUndefined(result) ? true : tagValidator(tag) + return isUndefinedOrNull(result) ? true : tagValidator(tag) }, getInput() { // Returns the input element reference (or null if not found) diff --git a/src/components/table/helpers/mixin-filtering.js b/src/components/table/helpers/mixin-filtering.js index 69a75e98554..ee10e78786e 100644 --- a/src/components/table/helpers/mixin-filtering.js +++ b/src/components/table/helpers/mixin-filtering.js @@ -5,7 +5,7 @@ import identity from '../../../utils/identity' import looseEqual from '../../../utils/loose-equal' import { concat } from '../../../utils/array' import { makePropsConfigurable } from '../../../utils/config' -import { isFunction, isString, isRegExp, isUndefined } from '../../../utils/inspect' +import {isFunction, isString, isRegExp, isUndefinedOrNull} from '../../../utils/inspect' import { toInteger } from '../../../utils/number' import { escapeRegExp } from '../../../utils/string' import { warn } from '../../../utils/warn' @@ -87,7 +87,7 @@ export default { try { result = filterFunction() } catch {} - return isUndefined(result) ? null : filterFunction + return isUndefinedOrNull(result) ? null : filterFunction }, // Returns the records in `localItems` that match the filter criteria // Returns the original `localItems` array if not sorting diff --git a/src/mixins/form-text.js b/src/mixins/form-text.js index 49f6050fa9c..248e1c5cb45 100644 --- a/src/mixins/form-text.js +++ b/src/mixins/form-text.js @@ -1,7 +1,7 @@ import { makePropsConfigurable } from '../utils/config' import { attemptBlur, attemptFocus } from '../utils/dom' import { stopEvent } from '../utils/events' -import { isUndefined } from '../utils/inspect' +import {isUndefined, isUndefinedOrNull} from '../utils/inspect' import { mathMax } from '../utils/math' import { toInteger, toFloat } from '../utils/number' import { toString } from '../utils/string' @@ -116,7 +116,7 @@ export default { try { result = this.formatter() } catch {} - return !isUndefined(result) + return !isUndefinedOrNull(result) } }, watch: { From 6aa5b140002012f6c591d6be6028392dabdc990a Mon Sep 17 00:00:00 2001 From: Moein Date: Fri, 20 Nov 2020 23:46:46 +0100 Subject: [PATCH 2/2] fix(generic): fixes on usage of isUndefined in many components and form-text mixin --- src/components/calendar/calendar.js | 2 +- src/components/form-file/form-file.js | 8 +------- src/components/form-spinbutton/form-spinbutton.js | 2 +- src/components/form-tags/form-tags.js | 2 +- src/components/table/helpers/mixin-filtering.js | 2 +- src/mixins/form-text.js | 2 +- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/components/calendar/calendar.js b/src/components/calendar/calendar.js index 3ec7c108ef4..e82fe43e4e9 100644 --- a/src/components/calendar/calendar.js +++ b/src/components/calendar/calendar.js @@ -43,7 +43,7 @@ import { } from '../../utils/date' import { attemptBlur, attemptFocus, requestAF } from '../../utils/dom' import { stopEvent } from '../../utils/events' -import {isArray, isPlainObject, isString, isUndefinedOrNull} from '../../utils/inspect' +import { isArray, isPlainObject, isString, isUndefinedOrNull } from '../../utils/inspect' import { isLocaleRTL } from '../../utils/locale' import { mathMax } from '../../utils/math' import { toInteger } from '../../utils/number' diff --git a/src/components/form-file/form-file.js b/src/components/form-file/form-file.js index edec487f90f..8d34f898375 100644 --- a/src/components/form-file/form-file.js +++ b/src/components/form-file/form-file.js @@ -10,13 +10,7 @@ import { makePropsConfigurable } from '../../utils/config' import { closest } from '../../utils/dom' import { hasPromiseSupport } from '../../utils/env' import { eventOn, eventOff, stopEvent } from '../../utils/events' -import { - isArray, - isFile, - isFunction, - isNull, - isUndefinedOrNull -} from '../../utils/inspect' +import { isArray, isFile, isFunction, isNull, isUndefinedOrNull } from '../../utils/inspect' import { File } from '../../utils/safe-types' import { escapeRegExp } from '../../utils/string' import { warn } from '../../utils/warn' diff --git a/src/components/form-spinbutton/form-spinbutton.js b/src/components/form-spinbutton/form-spinbutton.js index 561c9ce914a..c95d5531a0d 100644 --- a/src/components/form-spinbutton/form-spinbutton.js +++ b/src/components/form-spinbutton/form-spinbutton.js @@ -13,7 +13,7 @@ import { arrayIncludes, concat } from '../../utils/array' import { makePropsConfigurable } from '../../utils/config' import { attemptBlur, attemptFocus } from '../../utils/dom' import { eventOnOff, stopEvent } from '../../utils/events' -import {isNull, isUndefinedOrNull} from '../../utils/inspect' +import { isNull, isUndefinedOrNull } from '../../utils/inspect' import { isLocaleRTL } from '../../utils/locale' import { mathFloor, mathMax, mathPow, mathRound } from '../../utils/math' import { toFloat, toInteger } from '../../utils/number' diff --git a/src/components/form-tags/form-tags.js b/src/components/form-tags/form-tags.js index e323ced4c16..7c61d240b57 100644 --- a/src/components/form-tags/form-tags.js +++ b/src/components/form-tags/form-tags.js @@ -21,7 +21,7 @@ import { } from '../../utils/dom' import { stopEvent } from '../../utils/events' import { pick } from '../../utils/object' -import {isEvent, isNumber, isString, isUndefinedOrNull} from '../../utils/inspect' +import { isEvent, isNumber, isString, isUndefinedOrNull } from '../../utils/inspect' import { escapeRegExp, toString, trim, trimLeft } from '../../utils/string' import formControlMixin, { props as formControlProps } from '../../mixins/form-control' import formSizeMixin, { props as formSizeProps } from '../../mixins/form-size' diff --git a/src/components/table/helpers/mixin-filtering.js b/src/components/table/helpers/mixin-filtering.js index ee10e78786e..6a196002eb2 100644 --- a/src/components/table/helpers/mixin-filtering.js +++ b/src/components/table/helpers/mixin-filtering.js @@ -5,7 +5,7 @@ import identity from '../../../utils/identity' import looseEqual from '../../../utils/loose-equal' import { concat } from '../../../utils/array' import { makePropsConfigurable } from '../../../utils/config' -import {isFunction, isString, isRegExp, isUndefinedOrNull} from '../../../utils/inspect' +import { isFunction, isString, isRegExp, isUndefinedOrNull } from '../../../utils/inspect' import { toInteger } from '../../../utils/number' import { escapeRegExp } from '../../../utils/string' import { warn } from '../../../utils/warn' diff --git a/src/mixins/form-text.js b/src/mixins/form-text.js index 248e1c5cb45..e6f7ad432fc 100644 --- a/src/mixins/form-text.js +++ b/src/mixins/form-text.js @@ -1,7 +1,7 @@ import { makePropsConfigurable } from '../utils/config' import { attemptBlur, attemptFocus } from '../utils/dom' import { stopEvent } from '../utils/events' -import {isUndefined, isUndefinedOrNull} from '../utils/inspect' +import { isUndefinedOrNull } from '../utils/inspect' import { mathMax } from '../utils/math' import { toInteger, toFloat } from '../utils/number' import { toString } from '../utils/string'