From c497b92187b854198e2d579fae6bc2794584b631 Mon Sep 17 00:00:00 2001 From: Phiter Fernandes Date: Wed, 13 May 2020 16:14:41 -0300 Subject: [PATCH 1/2] fix(config): add attachToDocument conditional deprecation message resolves #1545 --- packages/shared/validate-options.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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` ) } From d5c9e0ca2cb7521cbb291c0bcd5033834ad20f03 Mon Sep 17 00:00:00 2001 From: Phiter Fernandes Date: Thu, 14 May 2020 11:05:14 -0300 Subject: [PATCH 2/2] test(config): add attachToDocument deprecation warning test --- test/specs/config.spec.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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') + ) + }) + }) })