Skip to content

Commit 35dacdc

Browse files
authored
Add attachToDocument conditional deprecation message, fix #1545 (#1546)
* fix(config): add attachToDocument conditional deprecation message resolves #1545 * test(config): add attachToDocument deprecation warning test
1 parent 44ac570 commit 35dacdc

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

packages/shared/validate-options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from './validators'
88
import { VUE_VERSION } from './consts'
99
import { compileTemplateForSlots } from './compile-template'
10-
import { throwError, warn } from './util'
10+
import { throwError, warnDeprecated } from './util'
1111
import { validateSlots } from './validate-slots'
1212

1313
function vueExtendUnsupportedOption(option) {
@@ -34,7 +34,7 @@ export function validateOptions(options, component) {
3434
)
3535
}
3636
if ('attachToDocument' in options) {
37-
warn(
37+
warnDeprecated(
3838
`options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release`
3939
)
4040
}

test/specs/config.spec.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describeWithShallowAndMount('config', mountingMethod => {
101101
expect(wrapper.find('[data-testid="expanded"]').exists()).to.equal(false)
102102
})
103103

104-
it('allows control deprecation warnings visibility', () => {
104+
it('allows control deprecation warnings visibility for name method', () => {
105105
config.showDeprecationWarnings = true
106106
const Component = {
107107
name: 'Foo',
@@ -114,4 +114,34 @@ describeWithShallowAndMount('config', mountingMethod => {
114114
wrapper.name()
115115
expect(console.error).to.have.callCount(1)
116116
})
117+
118+
describe('attachToDocument deprecation warning', () => {
119+
const Component = {
120+
name: 'Foo',
121+
template: '<div>Foo</div>'
122+
}
123+
124+
it('should show warning if config is enabled', () => {
125+
config.showDeprecationWarnings = true
126+
127+
mountingMethod(Component, {
128+
attachToDocument: true
129+
})
130+
expect(console.error).to.be.calledWith(
131+
sandbox.match('attachToDocument is deprecated')
132+
)
133+
})
134+
135+
it('should not show warning if config is disabled', () => {
136+
config.showDeprecationWarnings = false
137+
138+
mountingMethod(Component, {
139+
attachToDocument: true
140+
})
141+
142+
expect(console.error).not.to.be.calledWith(
143+
sandbox.match('attachToDocument is deprecated')
144+
)
145+
})
146+
})
117147
})

0 commit comments

Comments
 (0)