Skip to content
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

Add attachToDocument conditional deprecation message, fix #1545 #1546

Merged
merged 2 commits into from May 14, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/shared/validate-options.js
Expand Up @@ -7,7 +7,7 @@ import {
} from './validators'
import { VUE_VERSION } from './consts'
import { compileTemplateForSlots } from './compile-template'
import { throwError, warn } from './util'
import { throwError, warnDeprecated } from './util'
import { validateSlots } from './validate-slots'

function vueExtendUnsupportedOption(option) {
Expand All @@ -34,7 +34,7 @@ export function validateOptions(options, component) {
)
}
if ('attachToDocument' in options) {
warn(
warnDeprecated(
`options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release`
)
}
Expand Down
32 changes: 31 additions & 1 deletion test/specs/config.spec.js
Expand Up @@ -101,7 +101,7 @@ describeWithShallowAndMount('config', mountingMethod => {
expect(wrapper.find('[data-testid="expanded"]').exists()).to.equal(false)
})

it('allows control deprecation warnings visibility', () => {
it('allows control deprecation warnings visibility for name method', () => {
config.showDeprecationWarnings = true
const Component = {
name: 'Foo',
Expand All @@ -114,4 +114,34 @@ describeWithShallowAndMount('config', mountingMethod => {
wrapper.name()
expect(console.error).to.have.callCount(1)
})

describe('attachToDocument deprecation warning', () => {
const Component = {
name: 'Foo',
template: '<div>Foo</div>'
}

it('should show warning if config is enabled', () => {
config.showDeprecationWarnings = true

mountingMethod(Component, {
attachToDocument: true
})
expect(console.error).to.be.calledWith(
sandbox.match('attachToDocument is deprecated')
)
})

it('should not show warning if config is disabled', () => {
config.showDeprecationWarnings = false

mountingMethod(Component, {
attachToDocument: true
})

expect(console.error).not.to.be.calledWith(
sandbox.match('attachToDocument is deprecated')
)
})
})
})