diff --git a/packages/shared/validate-options.js b/packages/shared/validate-options.js index 452d64eb4..adfae6dbc 100644 --- a/packages/shared/validate-options.js +++ b/packages/shared/validate-options.js @@ -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) { @@ -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` ) } diff --git a/test/specs/config.spec.js b/test/specs/config.spec.js index 42456fd92..59acabaed 100644 --- a/test/specs/config.spec.js +++ b/test/specs/config.spec.js @@ -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', @@ -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: '
Foo
' + } + + 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') + ) + }) + }) })