feat(core): validate directives names (#326)

This commit is contained in:
Dmitry Sharshakov
2019-10-18 19:34:45 +03:00
committed by Evan You
parent 60961ef5b6
commit 2238925fbe
4 changed files with 55 additions and 4 deletions

View File

@@ -138,6 +138,11 @@ describe('api: createApp', () => {
expect(spy1).toHaveBeenCalled()
expect(spy2).not.toHaveBeenCalled()
expect(spy3).toHaveBeenCalled()
app.directive('bind', FooBar)
expect(
`Do not use built-in directive ids as custom directive id: bind`
).toHaveBeenWarned()
})
test('mixin', () => {
@@ -342,6 +347,33 @@ describe('api: createApp', () => {
).toHaveBeenWarned()
})
test('Component.directives', () => {
const app = createApp()
Object.defineProperty(app.config, 'isNativeTag', {
value: isNativeTag,
writable: false
})
const Root = {
directives: {
bind: () => {}
},
setup() {
return {
count: ref(0)
}
},
render() {
return null
}
}
app.mount(Root, nodeOps.createElement('div'))
expect(
`Do not use built-in directive ids as custom directive id: bind`
).toHaveBeenWarned()
})
test('register using app.component', () => {
const app = createApp()
Object.defineProperty(app.config, 'isNativeTag', {