Skip to content
Permalink
Browse files
fix: user supplied prop function detection (#6070)
  • Loading branch information
jacobmllr95 committed Nov 24, 2020
1 parent d6d8e3c commit cea6051
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 48 deletions.
@@ -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 } from '../../utils/inspect'
import { isLocaleRTL } from '../../utils/locale'
import { mathMax } from '../../utils/math'
import { toInteger } from '../../utils/number'
@@ -342,20 +342,12 @@ export const BCalendar = Vue.extend({
},
computedDateDisabledFn() {
const { dateDisabledFn } = this
let result = null
try {
result = dateDisabledFn()
} catch {}
return isUndefined(result) ? () => false : dateDisabledFn
return dateDisabledFn.name !== 'default' ? dateDisabledFn : () => false
},
// TODO: Change `dateInfoFn` to handle events and notes as well as classes
computedDateInfoFn() {
const { dateInfoFn } = this
let result = null
try {
result = dateInfoFn()
} catch {}
return isUndefined(result) ? () => ({}) : dateInfoFn
return dateInfoFn.name !== 'default' ? dateInfoFn : () => ({})
},
calendarLocale() {
// This locale enforces the gregorian calendar (for use in formatter functions)
@@ -10,14 +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,
isUndefined,
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'
@@ -276,11 +269,9 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
},
computedFileNameFormatter() {
const { fileNameFormatter } = this
let result = null
try {
result = fileNameFormatter()
} catch {}
return isUndefined(result) ? this.defaultFileNameFormatter : fileNameFormatter
return fileNameFormatter.name !== 'default'
? fileNameFormatter
: this.defaultFileNameFormatter
},
clonedFiles() {
return cloneDeep(this.files)
@@ -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 } from '../../utils/inspect'
import { isLocaleRTL } from '../../utils/locale'
import { mathFloor, mathMax, mathPow, mathRound } from '../../utils/math'
import { toFloat, toInteger } from '../../utils/number'
@@ -223,11 +223,7 @@ export const BFormSpinbutton = /*#__PURE__*/ Vue.extend({
},
computedFormatter() {
const { formatterFn } = this
let result = null
try {
result = formatterFn()
} catch {}
return isUndefined(result) ? this.defaultFormatter : formatterFn
return formatterFn.name !== 'default' ? formatterFn : this.defaultFormatter
},
computedAttrs() {
return {
@@ -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 } 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'
@@ -508,11 +508,7 @@ export const BFormTags = /*#__PURE__*/ Vue.extend({
},
validateTag(tag) {
const { tagValidator } = this
let result = null
try {
result = tagValidator()
} catch {}
return isUndefined(result) ? true : tagValidator(tag)
return tagValidator.name !== 'default' ? tagValidator(tag) : true
},
getInput() {
// Returns the input element reference (or null if not found)
@@ -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 } from '../../../utils/inspect'
import { toInteger } from '../../../utils/number'
import { escapeRegExp } from '../../../utils/string'
import { warn } from '../../../utils/warn'
@@ -83,11 +83,7 @@ export default {
localFilterFn() {
// Return `null` to signal to use internal filter function
const { filterFunction } = this
let result = null
try {
result = filterFunction()
} catch {}
return isUndefined(result) ? null : filterFunction
return filterFunction.name !== 'default' ? filterFunction : null
},
// Returns the records in `localItems` that match the filter criteria
// Returns the original `localItems` array if not sorting
@@ -1,7 +1,6 @@
import { makePropsConfigurable } from '../utils/config'
import { attemptBlur, attemptFocus } from '../utils/dom'
import { stopEvent } from '../utils/events'
import { isUndefined } from '../utils/inspect'
import { mathMax } from '../utils/math'
import { toInteger, toFloat } from '../utils/number'
import { toString } from '../utils/string'
@@ -113,11 +112,7 @@ export default {
return mathMax(toInteger(this.debounce, 0), 0)
},
hasFormatter() {
let result = null
try {
result = this.formatter()
} catch {}
return !isUndefined(result)
return this.formatter.name !== 'default'
}
},
watch: {

0 comments on commit cea6051

Please sign in to comment.