Skip to content

Commit 347c2a3

Browse files
committed
fix: user supplied prop function detection
1 parent 98e9ce1 commit 347c2a3

File tree

5 files changed

+247
-227
lines changed

5 files changed

+247
-227
lines changed

src/components/calendar/calendar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,14 @@ export const BCalendar = Vue.extend({
342342
},
343343
computedDateDisabledFn() {
344344
const { dateDisabledFn } = this
345-
return dateDisabledFn.name !== 'default' ? dateDisabledFn : () => false
345+
return dateDisabledFn.name !== props.dateDisabledFn.default.name
346+
? dateDisabledFn
347+
: () => false
346348
},
347349
// TODO: Change `dateInfoFn` to handle events and notes as well as classes
348350
computedDateInfoFn() {
349351
const { dateInfoFn } = this
350-
return dateInfoFn.name !== 'default' ? dateInfoFn : () => ({})
352+
return dateInfoFn.name !== props.dateInfoFn.default.name ? dateInfoFn : () => ({})
351353
},
352354
calendarLocale() {
353355
// This locale enforces the gregorian calendar (for use in formatter functions)

src/components/form-file/form-file.js

Lines changed: 79 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,83 @@ const getAllFileEntriesInDirectory = (directoryReader, path = '') =>
108108
readDirectoryEntries()
109109
})
110110

111+
// --- Props ---
112+
113+
const props = makePropsConfigurable(
114+
{
115+
...formControlProps,
116+
...formCustomProps,
117+
...formStateProps,
118+
...formSizeProps,
119+
value: {
120+
type: [File, Array],
121+
default: null,
122+
validator(value) {
123+
/* istanbul ignore next */
124+
if (value === '') {
125+
warn(VALUE_EMPTY_DEPRECATED_MSG, NAME_FORM_FILE)
126+
return true
127+
}
128+
return isUndefinedOrNull(value) || isValidValue(value)
129+
}
130+
},
131+
accept: {
132+
type: String,
133+
default: ''
134+
},
135+
// Instruct input to capture from camera
136+
capture: {
137+
type: Boolean,
138+
default: false
139+
},
140+
placeholder: {
141+
type: String,
142+
default: 'No file chosen'
143+
},
144+
browseText: {
145+
type: String,
146+
default: 'Browse'
147+
},
148+
dropPlaceholder: {
149+
type: String,
150+
default: 'Drop files here'
151+
},
152+
noDropPlaceholder: {
153+
type: String,
154+
default: 'Not allowed'
155+
},
156+
multiple: {
157+
type: Boolean,
158+
default: false
159+
},
160+
directory: {
161+
type: Boolean,
162+
default: false
163+
},
164+
// TODO:
165+
// Should we deprecate this and only support flat file structures?
166+
// Nested file structures are only supported when files are dropped
167+
// A Chromium "bug" prevents `webkitEntries` from being populated
168+
// on the file input's `change` event and is marked as "WontFix"
169+
// Mozilla implemented the behavior the same way as Chromium
170+
// See: https://bugs.chromium.org/p/chromium/issues/detail?id=138987
171+
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1326031
172+
noTraverse: {
173+
type: Boolean,
174+
default: false
175+
},
176+
noDrop: {
177+
type: Boolean,
178+
default: false
179+
},
180+
fileNameFormatter: {
181+
type: Function
182+
// default: null
183+
}
184+
},
185+
NAME_FORM_FILE
186+
)
187+
111188
// @vue/component
112189
export const BFormFile = /*#__PURE__*/ Vue.extend({
113190
name: NAME_FORM_FILE,
@@ -124,80 +201,7 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
124201
prop: 'value',
125202
event: 'input'
126203
},
127-
props: makePropsConfigurable(
128-
{
129-
...formControlProps,
130-
...formCustomProps,
131-
...formStateProps,
132-
...formSizeProps,
133-
value: {
134-
type: [File, Array],
135-
default: null,
136-
validator(value) {
137-
/* istanbul ignore next */
138-
if (value === '') {
139-
warn(VALUE_EMPTY_DEPRECATED_MSG, NAME_FORM_FILE)
140-
return true
141-
}
142-
return isUndefinedOrNull(value) || isValidValue(value)
143-
}
144-
},
145-
accept: {
146-
type: String,
147-
default: ''
148-
},
149-
// Instruct input to capture from camera
150-
capture: {
151-
type: Boolean,
152-
default: false
153-
},
154-
placeholder: {
155-
type: String,
156-
default: 'No file chosen'
157-
},
158-
browseText: {
159-
type: String,
160-
default: 'Browse'
161-
},
162-
dropPlaceholder: {
163-
type: String,
164-
default: 'Drop files here'
165-
},
166-
noDropPlaceholder: {
167-
type: String,
168-
default: 'Not allowed'
169-
},
170-
multiple: {
171-
type: Boolean,
172-
default: false
173-
},
174-
directory: {
175-
type: Boolean,
176-
default: false
177-
},
178-
// TODO:
179-
// Should we deprecate this and only support flat file structures?
180-
// Nested file structures are only supported when files are dropped
181-
// A Chromium "bug" prevents `webkitEntries` from being populated
182-
// on the file input's `change` event and is marked as "WontFix"
183-
// Mozilla implemented the behavior the same way as Chromium
184-
// See: https://bugs.chromium.org/p/chromium/issues/detail?id=138987
185-
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1326031
186-
noTraverse: {
187-
type: Boolean,
188-
default: false
189-
},
190-
noDrop: {
191-
type: Boolean,
192-
default: false
193-
},
194-
fileNameFormatter: {
195-
type: Function
196-
// default: null
197-
}
198-
},
199-
NAME_FORM_FILE
200-
),
204+
props,
201205
data() {
202206
return {
203207
files: [],
@@ -269,7 +273,7 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
269273
},
270274
computedFileNameFormatter() {
271275
const { fileNameFormatter } = this
272-
return fileNameFormatter.name !== 'default'
276+
return fileNameFormatter.name !== props.fileNameFormatter.default.name
273277
? fileNameFormatter
274278
: this.defaultFileNameFormatter
275279
},

src/components/form-spinbutton/form-spinbutton.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ export const BFormSpinbutton = /*#__PURE__*/ Vue.extend({
223223
},
224224
computedFormatter() {
225225
const { formatterFn } = this
226-
return formatterFn.name !== 'default' ? formatterFn : this.defaultFormatter
226+
return formatterFn.name !== props.formatterFn.default.name
227+
? formatterFn
228+
: this.defaultFormatter
227229
},
228230
computedAttrs() {
229231
return {

0 commit comments

Comments
 (0)