]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(runtime-core): warn incorrect root props value (close #375)
authorEvan You <yyx990803@gmail.com>
Mon, 9 Dec 2019 19:06:21 +0000 (14:06 -0500)
committerEvan You <yyx990803@gmail.com>
Mon, 9 Dec 2019 19:06:31 +0000 (14:06 -0500)
packages/runtime-core/src/apiApp.ts

index c526e84f580dfe60e707f13a015efee93ff268c4..71b75821f22fc089cf7b40a28349ce7457cb6271 100644 (file)
@@ -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<HostNode, HostElement>(
       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.