fix(runtime-core): component methods should override global properties in DEV (#3074)
This commit is contained in:
@@ -8,7 +8,8 @@ import {
|
||||
nextTick,
|
||||
renderToString,
|
||||
ref,
|
||||
defineComponent
|
||||
defineComponent,
|
||||
createApp
|
||||
} from '@vue/runtime-test'
|
||||
|
||||
describe('api: options', () => {
|
||||
@@ -105,6 +106,24 @@ describe('api: options', () => {
|
||||
expect(serializeInner(root)).toBe(`<div>2</div>`)
|
||||
})
|
||||
|
||||
test('component’s own methods have higher priority than global properties', async () => {
|
||||
const app = createApp({
|
||||
methods: {
|
||||
foo() {
|
||||
return 'foo'
|
||||
}
|
||||
},
|
||||
render() {
|
||||
return this.foo()
|
||||
}
|
||||
})
|
||||
app.config.globalProperties.foo = () => 'bar'
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
app.mount(root)
|
||||
expect(serializeInner(root)).toBe(`foo`)
|
||||
})
|
||||
|
||||
test('watch', async () => {
|
||||
function returnThis(this: any) {
|
||||
return this
|
||||
|
||||
Reference in New Issue
Block a user