Skip to content

Commit

Permalink
Add attachToDocument conditional deprecation message, fix #1545 (#1546)
Browse files Browse the repository at this point in the history
* fix(config): add attachToDocument conditional deprecation message

resolves #1545

* test(config): add attachToDocument deprecation warning test
  • Loading branch information
phiter committed May 14, 2020
1 parent 44ac570 commit 35dacdc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
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')
)
})
})
})

0 comments on commit 35dacdc

Please sign in to comment.