From: Evan You Date: Mon, 9 Dec 2019 19:06:21 +0000 (-0500) Subject: feat(runtime-core): warn incorrect root props value (close #375) X-Git-Tag: v3.0.0-alpha.0~93 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c53fae987d5b7980b7df48305e36f2c0ddf6c8a8;p=thirdparty%2Fvuejs%2Fcore.git feat(runtime-core): warn incorrect root props value (close #375) --- diff --git a/packages/runtime-core/src/apiApp.ts b/packages/runtime-core/src/apiApp.ts index c526e84f58..71b75821f2 100644 --- a/packages/runtime-core/src/apiApp.ts +++ b/packages/runtime-core/src/apiApp.ts @@ -4,7 +4,7 @@ import { ComponentPublicInstance } from './componentProxy' import { Directive, validateDirectiveName } from './directives' import { RootRenderFunction } from './renderer' import { InjectionKey } from './apiInject' -import { isFunction, NO } from '@vue/shared' +import { isFunction, NO, isObject } from '@vue/shared' import { warn } from './warning' import { createVNode } from './vnode' @@ -163,9 +163,14 @@ export function createAppAPI( mount( rootComponent: Component, rootContainer: HostElement, - rootProps?: Data + rootProps?: Data | null ): any { if (!isMounted) { + if (!isObject(rootProps)) { + __DEV__ && + warn(`root props passed to app.mount() must be an object.`) + rootProps = null + } const vnode = createVNode(rootComponent, rootProps) // store app context on the root VNode. // this will be set on the root instance on initial mount.