From: Evan You Date: Wed, 17 Oct 2018 21:35:03 +0000 (-0400) Subject: feat: warn missing render() function X-Git-Tag: v3.0.0-alpha.0~1093 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f936a0dfe165a1f9e96b1ebabab2491e300c5ef;p=thirdparty%2Fvuejs%2Fcore.git feat: warn missing render() function --- diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index 1ef89edcb8..e333554c4e 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -13,6 +13,7 @@ import { nextTick } from '@vue/scheduler' import { ErrorTypes } from './errorHandling' import { initializeComponentInstance } from './componentUtils' import { EventEmitter, invokeListeners } from './optional/eventEmitter' +import { warn } from './warning' // public component instance type export interface Component

extends PublicInstanceMethods { @@ -150,6 +151,15 @@ class InternalComponent implements PublicInstanceMethods { } } + // necessary to tell this apart from a functional + render(...args: any[]): any { + if (__DEV__) { + const name = + (this.$options && this.$options.displayName) || this.constructor.name + warn(`Class component \`${name}\` is missing render() method.`) + } + } + // to be set by renderer during mount $forceUpdate: () => void = NOOP diff --git a/packages/core/src/componentProxy.ts b/packages/core/src/componentProxy.ts index c1d9565086..a42e812d7e 100644 --- a/packages/core/src/componentProxy.ts +++ b/packages/core/src/componentProxy.ts @@ -42,7 +42,7 @@ const renderProxyHandlers = { // TODO warn non-present property } const value = Reflect.get(target, key, receiver) - if (isFunction(value)) { + if (key !== 'constructor' && isFunction(value)) { // auto bind return getBoundMethod(value, target, receiver) } else {