fix(runtime-core): component methods should override global properties in DEV (#3074)
This commit is contained in:
@@ -604,7 +604,17 @@ export function applyOptions(
|
||||
for (const key in methods) {
|
||||
const methodHandler = (methods as MethodOptions)[key]
|
||||
if (isFunction(methodHandler)) {
|
||||
ctx[key] = methodHandler.bind(publicThis)
|
||||
// In dev mode, we use the `createRenderContext` function to define methods to the proxy target,
|
||||
// and those are read-only but reconfigurable, so it needs to be redefined here
|
||||
if (__DEV__) {
|
||||
Object.defineProperty(ctx, key, {
|
||||
value: methodHandler.bind(publicThis),
|
||||
configurable: true,
|
||||
enumerable: false
|
||||
})
|
||||
} else {
|
||||
ctx[key] = methodHandler.bind(publicThis)
|
||||
}
|
||||
if (__DEV__) {
|
||||
checkDuplicateProperties!(OptionTypes.METHODS, key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user