refactor: move decorators into their own package
This commit is contained in:
@@ -24,13 +24,12 @@ export { nextTick } from '@vue/scheduler'
|
||||
|
||||
// Optional APIs
|
||||
// these are imported on-demand and can be tree-shaken
|
||||
export { applyDirectives } from './optional/directives'
|
||||
export { createAsyncComponent } from './optional/asyncComponent'
|
||||
export { KeepAlive } from './optional/keepAlive'
|
||||
export { applyDirectives } from './optional/directives'
|
||||
export { mixins } from './optional/mixins'
|
||||
export { EventEmitter } from './optional/eventEmitter'
|
||||
export { memoize } from './optional/memoize'
|
||||
export { prop } from './optional/propDecorator'
|
||||
|
||||
// flags & types
|
||||
export { ComponentType, ComponentClass, FunctionalComponent } from './component'
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { Component } from '../component'
|
||||
import { PropValidator } from '../componentOptions'
|
||||
import { camelize } from '@vue/shared'
|
||||
|
||||
export function prop(
|
||||
target: Component | PropValidator<any>,
|
||||
key?: string
|
||||
): any {
|
||||
if (key) {
|
||||
applyProp(target, key)
|
||||
} else {
|
||||
const options = target as PropValidator<any>
|
||||
return (target: any, key: string) => {
|
||||
applyProp(target, key, options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyProp(target: any, key: string, options: PropValidator<any> = {}) {
|
||||
// here `target` is the prototype of the component class
|
||||
Object.defineProperty(target, `__prop_${camelize(key)}`, {
|
||||
value: options
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user