Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(modal): remove BvModalEvent deprecations #3864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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