Skip to content
Permalink
Browse files

feat(modal): remove BvModalEvent deprecations (#3864)

  • Loading branch information...
jackmu95 authored and tmorehouse committed Aug 13, 2019
1 parent bea49d4 commit 90c299cd169c709ee3b0e7525039ddc974a8f6df
@@ -1,5 +1,4 @@
import BvEvent from '../../../utils/bv-event.class'
import warn from '../../../utils/warn'
import { defineProperties, readonlyDescriptor } from '../../../utils/object'

class BvModalEvent extends BvEvent {
@@ -11,18 +10,6 @@ class BvModalEvent extends BvEvent {
})
}

get modalId() /* istanbul ignore next */ {
// Backwards compatability <= 2.0.0-rc.19
warn('b-modal: evt.modalId is deprecated. Please use evt.componentId.')
return this.componentId
}

cancel() /* istanbul ignore next */ {
// Backwards compatibility for BootstrapVue 1.x
warn('b-modal: evt.cancel() is deprecated. Please use evt.preventDefault().')
this.preventDefault()
}

static get Defaults() {
return {
...super.Defaults,
@@ -68,15 +68,6 @@ describe('modal > BvModalEvent', () => {
}
expect(failed).toBe(true)
expect(evt.trigger).toBe('ok')

failed = false
try {
evt.modalId = 'fail'
} catch (e) {
failed = true
}
expect(failed).toBe(true)
expect(evt.componentId).toBe('foo')
})

it('supports custom properties', async () => {
@@ -88,48 +79,4 @@ describe('modal > BvModalEvent', () => {
expect(evt.cancelable).toBe(true)
expect(evt.custom).toBe(123)
})

describe('Deprecated features', () => {
it('supports cancelable events via deprecated evt.cancel()', async () => {
// Mock `console.warn()` to prevent a console warning and
// check wether a warning about the `evt.cancel()` call
// was made
const warn = console.warn
console.warn = jest.fn()

const evt = new BvModalEvent('foobar', {
cancelable: true
})

expect(evt).toBeInstanceOf(BvModalEvent)
expect(evt.type).toBe('foobar')
expect(evt.cancelable).toBe(true)
expect(evt.defaultPrevented).toBe(false)
evt.cancel()
expect(evt.defaultPrevented).toBe(true)

expect(console.warn).toHaveBeenCalled()
console.warn = warn
})

it('supports deprecated evt.modalId', async () => {
// Mock `console.warn()` to prevent a console warning and
// check wether a warning about the `evt.cancel()` call
// was made
const warn = console.warn
console.warn = jest.fn()

const evt = new BvModalEvent('foobar', {
componentId: 'foo'
})

expect(evt).toBeInstanceOf(BvModalEvent)
expect(evt.type).toBe('foobar')
expect(evt.componentId).toBe('foo')
expect(evt.modalId).toBe('foo')

expect(console.warn).toHaveBeenCalled()
console.warn = warn
})
})
})
@@ -1,34 +1,25 @@
//
// Modals
//
// --- Modals ---
import Vue, { VNode } from 'vue'
import { BvPlugin, BvComponent, BvEvent } from '../../'

// Modal Plugin
// Modal plugin
export declare const ModalPlugin: BvPlugin

// Component: b-modal
// Component: <b-modal>
export declare class BModal extends BvComponent {
// Public methods
show: () => void
hide: (trigger?: string) => void
}

//
// Types
//
// --- Types ---
export type BvMsgBoxData = boolean | null | BvModalEvent | any

//
// Interfaces
//
// --- Interfaces ---
export interface BvModalEvent extends BvEvent {
readonly trigger: string | null
// Future
// details: any | null
// Deprecated
readonly modalId: string | null
cancel: () => void
}

export interface BvMsgBoxOptions {
@@ -95,9 +86,7 @@ export interface BvModal {
hide: (id: string) => void
}

//
// Vue Prototype Injections
//
// --- Vue prototype injections ---
declare module 'vue/types/vue' {
interface Vue {
// Modal injection

0 comments on commit 90c299c

Please sign in to comment.
You can’t perform that action at this time.