22// Based loosely on https://adamwathan.me/renderless-components-in-vuejs/
33import { Vue } from '../../vue'
44import { NAME_FORM_TAGS } from '../../constants/components'
5- import { EVENT_NAME_TAG_STATE , EVENT_OPTIONS_PASSIVE } from '../../constants/events'
5+ import {
6+ EVENT_NAME_BLUR ,
7+ EVENT_NAME_FOCUS ,
8+ EVENT_NAME_FOCUSIN ,
9+ EVENT_NAME_FOCUSOUT ,
10+ EVENT_NAME_TAG_STATE ,
11+ EVENT_OPTIONS_PASSIVE
12+ } from '../../constants/events'
613import { CODE_BACKSPACE , CODE_DELETE , CODE_ENTER } from '../../constants/key-codes'
714import {
815 PROP_TYPE_ARRAY ,
@@ -24,7 +31,7 @@ import { identity } from '../../utils/identity'
2431import { isEvent , isNumber , isString } from '../../utils/inspect'
2532import { looseEqual } from '../../utils/loose-equal'
2633import { makeModelMixin } from '../../utils/model'
27- import { pick , sortKeys } from '../../utils/object'
34+ import { omit , pick , sortKeys } from '../../utils/object'
2835import { hasPropFunction , makeProp , makePropsConfigurable } from '../../utils/props'
2936import { escapeRegExp , toString , trim , trimLeft } from '../../utils/string'
3037import { formControlMixin , props as formControlProps } from '../../mixins/form-control'
@@ -181,18 +188,13 @@ export const BFormTags = /*#__PURE__*/ Vue.extend({
181188 } ,
182189 computedInputHandlers ( ) {
183190 return {
184- ...pick (
185- this . bvListeners ,
186- Object . keys ( this . bvListeners ) . filter (
187- key => ! [ 'focus' , 'blur' , 'focusin' , 'focusout' ] . includes ( key )
188- )
189- ) ,
190- input : this . onInputInput ,
191+ ...omit ( this . bvListeners , [ EVENT_NAME_FOCUSIN , EVENT_NAME_FOCUSOUT ] ) ,
192+ blur : this . onInputBlur ,
191193 change : this . onInputChange ,
192- keydown : this . onInputKeydown ,
193- reset : this . reset ,
194194 focus : this . onInputFocus ,
195- blur : this . onInputBlur
195+ input : this . onInputInput ,
196+ keydown : this . onInputKeydown ,
197+ reset : this . reset
196198 }
197199 } ,
198200 computedSeparator ( ) {
@@ -420,42 +422,38 @@ export const BFormTags = /*#__PURE__*/ Vue.extend({
420422 }
421423 } ,
422424 onInputFocus ( event ) {
423- if ( typeof this . bvListeners . focus === 'function' && this . focusState !== 'out' ) {
425+ if ( this . focusState !== 'out' ) {
424426 this . focusState = 'in'
425427 this . $nextTick ( ( ) => {
426428 requestAF ( ( ) => {
427429 if ( this . hasFocus ) {
428- this . bvListeners . focus ( event )
430+ this . $emit ( EVENT_NAME_FOCUS , event )
429431 this . focusState = null
430432 }
431433 } )
432434 } )
433435 }
434436 } ,
435437 onInputBlur ( event ) {
436- if ( typeof this . bvListeners . blur === 'function' && this . focusState !== 'in' ) {
438+ if ( this . focusState !== 'in' ) {
437439 this . focusState = 'out'
438440 this . $nextTick ( ( ) => {
439441 requestAF ( ( ) => {
440442 if ( ! this . hasFocus ) {
441- this . bvListeners . blur ( event )
443+ this . $emit ( EVENT_NAME_BLUR , event )
442444 this . focusState = null
443445 }
444446 } )
445447 } )
446448 }
447449 } ,
448- onFocusin ( e ) {
450+ onFocusin ( event ) {
449451 this . hasFocus = true
450- if ( typeof this . bvListeners . focusin === 'function' ) {
451- this . bvListeners . focusin ( e )
452- }
452+ this . $emit ( EVENT_NAME_FOCUSIN , event )
453453 } ,
454- onFocusout ( e ) {
454+ onFocusout ( event ) {
455455 this . hasFocus = false
456- if ( typeof this . bvListeners . focusout === 'function' ) {
457- this . bvListeners . focusout ( e )
458- }
456+ this . $emit ( EVENT_NAME_FOCUSOUT , event )
459457 } ,
460458 handleAutofocus ( ) {
461459 this . $nextTick ( ( ) => {
0 commit comments