refactor: move prop decorator into core, expose initial props to initialziers
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
import { PropValidator, Component } from '@vue/runtime-core'
|
||||
|
||||
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_${key}`, {
|
||||
value: options
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user