Skip to content

Commit

Permalink
feat(modal): remove BvModalEvent deprecations (#3864)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmllr95 authored and tmorehouse committed Aug 13, 2019
1 parent bea49d4 commit 90c299c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 83 deletions.
13 changes: 0 additions & 13 deletions src/components/modal/helpers/bv-modal-event.class.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand Down
53 changes: 0 additions & 53 deletions src/components/modal/helpers/bv-modal-event.class.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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
})
})
})
23 changes: 6 additions & 17 deletions src/components/modal/index.d.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 90c299c

Please sign in to comment.