OPTIONS_DATA_FN,
OPTIONS_DATA_MERGE,
OPTIONS_BEFORE_DESTROY,
- OPTIONS_DESTROYED
+ OPTIONS_DESTROYED,
+
+ PROPS_DEFAULT_THIS
}
type DeprecationData = {
[DeprecationTypes.OPTIONS_DATA_MERGE]: {
message: (key: string) =>
- `Detected conflicting key "${key}" when merging "data" option values. ` +
+ `Detected conflicting key "${key}" when merging data option values. ` +
`In Vue 3, data keys are merged shallowly and will override one another.`,
link: `https://v3.vuejs.org/guide/migration/data-option.html#mixin-merge-behavior-change`
},
[DeprecationTypes.OPTIONS_DESTROYED]: {
message: `\`destroyed\` has been renamed to \`unmounted\`.`
+ },
+
+ [DeprecationTypes.PROPS_DEFAULT_THIS]: {
+ message: (key: string) =>
+ `props default value function no longer has access to "this". ` +
+ `(found in prop "${key}")`,
+ link: `https://v3.vuejs.org/guide/migration/props-default-this.html`
}
}
--- /dev/null
+import { DeprecationTypes, warnDeprecation } from './deprecations'
+
+export function createPropsDefaultThis(propKey: string) {
+ return new Proxy(
+ {},
+ {
+ get() {
+ warnDeprecation(DeprecationTypes.PROPS_DEFAULT_THIS, propKey)
+ }
+ }
+ )
+}
import { isEmitListener } from './componentEmits'
import { InternalObjectKey } from './vnode'
import { AppContext } from './apiCreateApp'
+import { createPropsDefaultThis } from './compat/props'
export type ComponentPropsOptions<P = Data> =
| ComponentObjectPropsOptions<P>
value = propsDefaults[key]
} else {
setCurrentInstance(instance)
- value = propsDefaults[key] = defaultValue(props)
+ value = propsDefaults[key] =
+ __COMPAT__ && __DEV__
+ ? defaultValue.call(createPropsDefaultThis(key), props)
+ : defaultValue(props)
setCurrentInstance(null)
}
} else {